change return value, import ISelectionPosition

This commit is contained in:
Miguel Roncancio
2019-10-21 23:49:28 -04:00
parent d02086e5c6
commit 5d547bffb0
+7 -7
View File
@@ -3,7 +3,7 @@
* @license MIT * @license MIT
*/ */
import { Terminal, IDisposable, ITerminalAddon } from 'xterm'; import { Terminal, IDisposable, ITerminalAddon, ISelectionPosition } from 'xterm';
export interface ISearchOptions { export interface ISearchOptions {
regex?: boolean; regex?: boolean;
@@ -59,7 +59,7 @@ export class SearchAddon implements ITerminalAddon {
let startCol = 0; let startCol = 0;
let startRow = 0; let startRow = 0;
let currentSelection = null; let currentSelection: ISelectionPosition | undefined = undefined;
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
@@ -97,8 +97,8 @@ export class SearchAddon implements ITerminalAddon {
} }
} }
// If there is only one result, return false. // If there is only one result, return true.
if (!result && currentSelection) return false; if (!result && currentSelection) return true;
// 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);
@@ -126,7 +126,7 @@ 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; let currentSelection: ISelectionPosition | undefined = undefined;
if (this._terminal.hasSelection()) { if (this._terminal.hasSelection()) {
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
@@ -165,8 +165,8 @@ export class SearchAddon implements ITerminalAddon {
} }
} }
// If there is only one result, return false. // If there is only one result, return true.
if (!result && currentSelection) return false; if (!result && currentSelection) return true;
// 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);