change return value, import ISelectionPosition

This commit is contained in:
Miguel Roncancio
2019-10-21 23:39:01 -04:00
parent d02086e5c6
commit 495f97cf95
+5 -5
View File
@@ -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
@@ -98,7 +98,7 @@ export class SearchAddon implements ITerminalAddon {
}
// If there is only one result, return false.
if (!result && currentSelection) return false;
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
@@ -166,7 +166,7 @@ export class SearchAddon implements ITerminalAddon {
}
// If there is only one result, return false.
if (!result && currentSelection) return false;
if (!result && currentSelection) return true;
// Set selection and scroll if a result was found
return this._selectResult(result);