Prevent search result from being deselected if it is the only result

remove leading whitespace
prevent single search term deselection in findPrevious
This commit is contained in:
miguel
2019-10-21 15:58:44 -04:00
parent 631107698e
commit 449ede1d57
+10 -3
View File
@@ -59,12 +59,12 @@ export class SearchAddon implements ITerminalAddon {
let startCol = 0;
let startRow = 0;
let currentSelection = null;
if (this._terminal.hasSelection()) {
const incremental = searchOptions ? searchOptions.incremental : false;
// Start from the selection end if there is a selection
// For incremental search, use existing row
const currentSelection = this._terminal.getSelectionPosition()!;
currentSelection = this._terminal.getSelectionPosition()!;
startRow = incremental ? currentSelection.startRow : currentSelection.endRow;
startCol = incremental ? currentSelection.startColumn : currentSelection.endColumn;
}
@@ -97,6 +97,9 @@ export class SearchAddon implements ITerminalAddon {
}
}
// If there is only one result, return false.
if (!result && currentSelection) return false;
// Set selection and scroll if a result was found
return this._selectResult(result);
}
@@ -123,8 +126,9 @@ export class SearchAddon implements ITerminalAddon {
let startCol = this._terminal.cols;
let result: ISearchResult | undefined = undefined;
const incremental = searchOptions ? searchOptions.incremental : false;
let currentSelection = null;
if (this._terminal.hasSelection()) {
const currentSelection = this._terminal.getSelectionPosition()!;
currentSelection = this._terminal.getSelectionPosition()!;
// Start from selection start if there is a selection
startRow = currentSelection.startRow;
startCol = currentSelection.startColumn;
@@ -161,6 +165,9 @@ export class SearchAddon implements ITerminalAddon {
}
}
// If there is only one result, return false.
if (!result && currentSelection) return false;
// Set selection and scroll if a result was found
return this._selectResult(result);
}