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:
@@ -59,12 +59,12 @@ export class SearchAddon implements ITerminalAddon {
|
|||||||
|
|
||||||
let startCol = 0;
|
let startCol = 0;
|
||||||
let startRow = 0;
|
let startRow = 0;
|
||||||
|
let currentSelection = null;
|
||||||
if (this._terminal.hasSelection()) {
|
if (this._terminal.hasSelection()) {
|
||||||
const incremental = searchOptions ? searchOptions.incremental : false;
|
const incremental = searchOptions ? searchOptions.incremental : false;
|
||||||
// Start from the selection end if there is a selection
|
// Start from the selection end if there is a selection
|
||||||
// For incremental search, use existing row
|
// For incremental search, use existing row
|
||||||
const currentSelection = this._terminal.getSelectionPosition()!;
|
currentSelection = this._terminal.getSelectionPosition()!;
|
||||||
startRow = incremental ? currentSelection.startRow : currentSelection.endRow;
|
startRow = incremental ? currentSelection.startRow : currentSelection.endRow;
|
||||||
startCol = incremental ? currentSelection.startColumn : currentSelection.endColumn;
|
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
|
// Set selection and scroll if a result was found
|
||||||
return this._selectResult(result);
|
return this._selectResult(result);
|
||||||
}
|
}
|
||||||
@@ -123,8 +126,9 @@ export class SearchAddon implements ITerminalAddon {
|
|||||||
let startCol = this._terminal.cols;
|
let startCol = this._terminal.cols;
|
||||||
let result: ISearchResult | undefined = undefined;
|
let result: ISearchResult | undefined = undefined;
|
||||||
const incremental = searchOptions ? searchOptions.incremental : false;
|
const incremental = searchOptions ? searchOptions.incremental : false;
|
||||||
|
let currentSelection = null;
|
||||||
if (this._terminal.hasSelection()) {
|
if (this._terminal.hasSelection()) {
|
||||||
const currentSelection = this._terminal.getSelectionPosition()!;
|
currentSelection = this._terminal.getSelectionPosition()!;
|
||||||
// Start from selection start if there is a selection
|
// Start from selection start if there is a selection
|
||||||
startRow = currentSelection.startRow;
|
startRow = currentSelection.startRow;
|
||||||
startCol = currentSelection.startColumn;
|
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
|
// Set selection and scroll if a result was found
|
||||||
return this._selectResult(result);
|
return this._selectResult(result);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user