Incremental previous search

This commit is contained in:
Logan Ramos
2019-07-24 16:01:07 -07:00
parent f3f52e6920
commit d104f39a9d
2 changed files with 7 additions and 6 deletions
+4 -3
View File
@@ -126,10 +126,11 @@ export class SearchAddon implements ITerminalAddon {
const isReverseSearch = true;
let startRow = this._terminal.buffer.baseY + this._terminal.rows;
let startCol = this._terminal.cols;
let result: ISearchResult | undefined = undefined;
const incremental = searchOptions ? searchOptions.incremental : false;
if (this._terminal.hasSelection()) {
// Start from the selection start if there is a selection
const currentSelection = this._terminal.getSelectionPosition()!;
// Start from selection start if there is a selection
startRow = currentSelection.startRow;
startCol = currentSelection.startColumn;
}
@@ -137,7 +138,7 @@ export class SearchAddon implements ITerminalAddon {
this._initLinesCache();
// 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
if (!result) {
+3 -3
View File
@@ -140,9 +140,9 @@ function createTerminal(): void {
});
addDomListener(actionElements.findPrevious, 'keyup', (e) => {
if (e.key === `Enter`) {
searchAddon.findPrevious(actionElements.findPrevious.value, getSearchOptions());
}
const searchOptions = getSearchOptions();
searchOptions.incremental = e.key !== `Enter`;
searchAddon.findPrevious(actionElements.findPrevious.value, searchOptions);
});
// fit is called within a setTimeout, cols and rows need this.