Use new APIs in selection addon
This commit is contained in:
@@ -8,7 +8,6 @@ import { Terminal } from 'xterm';
|
|||||||
// TODO: Don't rely on this private API
|
// TODO: Don't rely on this private API
|
||||||
export interface ITerminalCore {
|
export interface ITerminalCore {
|
||||||
buffer: any;
|
buffer: any;
|
||||||
selectionManager: any;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ISearchAddonTerminal extends Terminal {
|
export interface ISearchAddonTerminal extends Terminal {
|
||||||
|
|||||||
@@ -35,25 +35,23 @@ export class SearchHelper implements ISearchHelper {
|
|||||||
* @return Whether a result was found.
|
* @return Whether a result was found.
|
||||||
*/
|
*/
|
||||||
public findNext(term: string, searchOptions?: ISearchOptions): boolean {
|
public findNext(term: string, searchOptions?: ISearchOptions): boolean {
|
||||||
const selectionManager = this._terminal._core.selectionManager;
|
|
||||||
const {incremental} = searchOptions;
|
const {incremental} = searchOptions;
|
||||||
let result: ISearchResult;
|
let result: ISearchResult;
|
||||||
|
|
||||||
if (!term || term.length === 0) {
|
if (!term || term.length === 0) {
|
||||||
selectionManager.clearSelection();
|
this._terminal.clearSelection();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let startCol: number = 0;
|
let startCol: number = 0;
|
||||||
let startRow = this._terminal._core.buffer.ydisp;
|
let startRow = this._terminal._core.buffer.ydisp;
|
||||||
|
|
||||||
if (selectionManager.selectionEnd) {
|
if (this._terminal.hasSelection()) {
|
||||||
// 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
|
||||||
if (this._terminal.getSelection().length !== 0) {
|
const currentSelection = this._terminal.getSelectionPosition();
|
||||||
startRow = incremental ? selectionManager.selectionStart[1] : selectionManager.selectionEnd[1];
|
startRow = incremental ? currentSelection.startRow : currentSelection.endRow;
|
||||||
startCol = incremental ? selectionManager.selectionStart[0] : selectionManager.selectionEnd[0];
|
startCol = incremental ? currentSelection.startColumn : currentSelection.endColumn;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this._initLinesCache();
|
this._initLinesCache();
|
||||||
@@ -109,11 +107,10 @@ export class SearchHelper implements ISearchHelper {
|
|||||||
* @return Whether a result was found.
|
* @return Whether a result was found.
|
||||||
*/
|
*/
|
||||||
public findPrevious(term: string, searchOptions?: ISearchOptions): boolean {
|
public findPrevious(term: string, searchOptions?: ISearchOptions): boolean {
|
||||||
const selectionManager = this._terminal._core.selectionManager;
|
|
||||||
let result: ISearchResult;
|
let result: ISearchResult;
|
||||||
|
|
||||||
if (!term || term.length === 0) {
|
if (!term || term.length === 0) {
|
||||||
selectionManager.clearSelection();
|
this._terminal.clearSelection();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,12 +118,11 @@ export class SearchHelper implements ISearchHelper {
|
|||||||
let startRow = this._terminal._core.buffer.ydisp + this._terminal.rows - 1;
|
let startRow = this._terminal._core.buffer.ydisp + this._terminal.rows - 1;
|
||||||
let startCol = this._terminal.cols;
|
let startCol = this._terminal.cols;
|
||||||
|
|
||||||
if (selectionManager.selectionStart) {
|
if (this._terminal.hasSelection()) {
|
||||||
// Start from the selection start if there is a selection
|
// Start from the selection start if there is a selection
|
||||||
if (this._terminal.getSelection().length !== 0) {
|
const currentSelection = this._terminal.getSelectionPosition();
|
||||||
startRow = selectionManager.selectionStart[1];
|
startRow = currentSelection.startRow;
|
||||||
startCol = selectionManager.selectionStart[0];
|
startCol = currentSelection.startColumn;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this._initLinesCache();
|
this._initLinesCache();
|
||||||
|
|||||||
Reference in New Issue
Block a user