diff --git a/addons/xterm-addon-search/src/SearchAddon.ts b/addons/xterm-addon-search/src/SearchAddon.ts index 3c12e4f1..cfee3cb9 100644 --- a/addons/xterm-addon-search/src/SearchAddon.ts +++ b/addons/xterm-addon-search/src/SearchAddon.ts @@ -3,7 +3,7 @@ * @license MIT */ -import { Terminal, IDisposable, ITerminalAddon } from 'xterm'; +import { Terminal, IDisposable, ITerminalAddon, ISelectionPosition } from 'xterm'; export interface ISearchOptions { regex?: boolean; @@ -59,7 +59,7 @@ export class SearchAddon implements ITerminalAddon { let startCol = 0; let startRow = 0; - let currentSelection = null; + let currentSelection: ISelectionPosition | undefined = undefined; if (this._terminal.hasSelection()) { const incremental = searchOptions ? searchOptions.incremental : false; // Start from the selection end if there is a selection @@ -97,8 +97,8 @@ export class SearchAddon implements ITerminalAddon { } } - // If there is only one result, return false. - if (!result && currentSelection) return false; + // If there is only one result, return true. + if (!result && currentSelection) return true; // Set selection and scroll if a result was found return this._selectResult(result); @@ -126,7 +126,7 @@ export class SearchAddon implements ITerminalAddon { let startCol = this._terminal.cols; let result: ISearchResult | undefined = undefined; const incremental = searchOptions ? searchOptions.incremental : false; - let currentSelection = null; + let currentSelection: ISelectionPosition | undefined = undefined; if (this._terminal.hasSelection()) { currentSelection = this._terminal.getSelectionPosition()!; // Start from selection start if there is a selection @@ -165,8 +165,8 @@ export class SearchAddon implements ITerminalAddon { } } - // If there is only one result, return false. - if (!result && currentSelection) return false; + // If there is only one result, return true. + if (!result && currentSelection) return true; // Set selection and scroll if a result was found return this._selectResult(result);