Incremental previous search
This commit is contained in:
@@ -126,10 +126,11 @@ export class SearchAddon implements ITerminalAddon {
|
|||||||
const isReverseSearch = true;
|
const isReverseSearch = true;
|
||||||
let startRow = this._terminal.buffer.baseY + this._terminal.rows;
|
let startRow = this._terminal.buffer.baseY + this._terminal.rows;
|
||||||
let startCol = this._terminal.cols;
|
let startCol = this._terminal.cols;
|
||||||
|
let result: ISearchResult | undefined = undefined;
|
||||||
|
const incremental = searchOptions ? searchOptions.incremental : false;
|
||||||
if (this._terminal.hasSelection()) {
|
if (this._terminal.hasSelection()) {
|
||||||
// Start from the selection start if there is a selection
|
|
||||||
const currentSelection = this._terminal.getSelectionPosition()!;
|
const currentSelection = this._terminal.getSelectionPosition()!;
|
||||||
|
// Start from selection start if there is a selection
|
||||||
startRow = currentSelection.startRow;
|
startRow = currentSelection.startRow;
|
||||||
startCol = currentSelection.startColumn;
|
startCol = currentSelection.startColumn;
|
||||||
}
|
}
|
||||||
@@ -137,7 +138,7 @@ export class SearchAddon implements ITerminalAddon {
|
|||||||
this._initLinesCache();
|
this._initLinesCache();
|
||||||
|
|
||||||
// Search startRow
|
// Search startRow
|
||||||
let result = this._findInLine(term, startRow, startCol, searchOptions, isReverseSearch);
|
result = incremental ? this._findInLine(term, startRow, startCol, searchOptions, false) : this._findInLine(term, startRow, startCol, searchOptions, isReverseSearch);
|
||||||
|
|
||||||
// Search from startRow - 1 to top
|
// Search from startRow - 1 to top
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
|||||||
+3
-3
@@ -140,9 +140,9 @@ function createTerminal(): void {
|
|||||||
});
|
});
|
||||||
|
|
||||||
addDomListener(actionElements.findPrevious, 'keyup', (e) => {
|
addDomListener(actionElements.findPrevious, 'keyup', (e) => {
|
||||||
if (e.key === `Enter`) {
|
const searchOptions = getSearchOptions();
|
||||||
searchAddon.findPrevious(actionElements.findPrevious.value, getSearchOptions());
|
searchOptions.incremental = e.key !== `Enter`;
|
||||||
}
|
searchAddon.findPrevious(actionElements.findPrevious.value, searchOptions);
|
||||||
});
|
});
|
||||||
|
|
||||||
// fit is called within a setTimeout, cols and rows need this.
|
// fit is called within a setTimeout, cols and rows need this.
|
||||||
|
|||||||
Reference in New Issue
Block a user