Merge branch 'lramos15/searchaddon-change' into search-tests
This commit is contained in:
@@ -57,7 +57,7 @@ export class SearchAddon implements ITerminalAddon {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let startCol: number = 0;
|
let startCol = 0;
|
||||||
let startRow = 0;
|
let startRow = 0;
|
||||||
|
|
||||||
if (this._terminal.hasSelection()) {
|
if (this._terminal.hasSelection()) {
|
||||||
@@ -71,13 +71,8 @@ export class SearchAddon implements ITerminalAddon {
|
|||||||
|
|
||||||
this._initLinesCache();
|
this._initLinesCache();
|
||||||
|
|
||||||
// A row that has isWrapped = false
|
|
||||||
const findingRow = startRow;
|
|
||||||
// index of beginning column that _findInLine need to scan.
|
|
||||||
const cumulativeCols = startCol;
|
|
||||||
|
|
||||||
// Search startRow
|
// Search startRow
|
||||||
let result = this._findInLine(term, findingRow, cumulativeCols, searchOptions);
|
let result = this._findInLine(term, startRow, startCol, searchOptions);
|
||||||
|
|
||||||
// Search from startRow + 1 to end
|
// Search from startRow + 1 to end
|
||||||
if (!result) {
|
if (!result) {
|
||||||
@@ -126,18 +121,25 @@ export class SearchAddon implements ITerminalAddon {
|
|||||||
const isReverseSearch = true;
|
const isReverseSearch = true;
|
||||||
let startRow = this._terminal.buffer.baseY + this._terminal.rows;
|
let startRow = this._terminal.buffer.baseY + this._terminal.rows;
|
||||||
let startCol = this._terminal.cols;
|
let startCol = this._terminal.cols;
|
||||||
|
let result: ISearchResult | undefined = undefined;
|
||||||
|
const incremental = searchOptions ? searchOptions.incremental : false;
|
||||||
if (this._terminal.hasSelection()) {
|
if (this._terminal.hasSelection()) {
|
||||||
// Start from the selection start if there is a selection
|
|
||||||
const currentSelection = this._terminal.getSelectionPosition()!;
|
const currentSelection = this._terminal.getSelectionPosition()!;
|
||||||
|
// Start from selection start if there is a selection
|
||||||
startRow = currentSelection.startRow;
|
startRow = currentSelection.startRow;
|
||||||
startCol = currentSelection.startColumn;
|
startCol = currentSelection.startColumn;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._initLinesCache();
|
this._initLinesCache();
|
||||||
|
|
||||||
// Search startRow
|
if (incremental) {
|
||||||
let result = this._findInLine(term, startRow, startCol, searchOptions, isReverseSearch);
|
result = this._findInLine(term, startRow, startCol, searchOptions, false);
|
||||||
|
if (!(result && result.row === startRow && result.col === startCol)) {
|
||||||
|
result = this._findInLine(term, startRow, startCol, searchOptions, true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
result = this._findInLine(term, startRow, startCol, searchOptions, isReverseSearch);
|
||||||
|
}
|
||||||
|
|
||||||
// Search from startRow - 1 to top
|
// Search from startRow - 1 to top
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
|||||||
+5
-8
@@ -58,11 +58,12 @@ function setPadding(): void {
|
|||||||
term.fit();
|
term.fit();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSearchOptions(): ISearchOptions {
|
function getSearchOptions(e: KeyboardEvent): ISearchOptions {
|
||||||
return {
|
return {
|
||||||
regex: (document.getElementById('regex') as HTMLInputElement).checked,
|
regex: (document.getElementById('regex') as HTMLInputElement).checked,
|
||||||
wholeWord: (document.getElementById('whole-word') as HTMLInputElement).checked,
|
wholeWord: (document.getElementById('whole-word') as HTMLInputElement).checked,
|
||||||
caseSensitive: (document.getElementById('case-sensitive') as HTMLInputElement).checked
|
caseSensitive: (document.getElementById('case-sensitive') as HTMLInputElement).checked,
|
||||||
|
incremental: e.key !== `Enter`
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,15 +135,11 @@ function createTerminal(): void {
|
|||||||
addDomListener(paddingElement, 'change', setPadding);
|
addDomListener(paddingElement, 'change', setPadding);
|
||||||
|
|
||||||
addDomListener(actionElements.findNext, 'keyup', (e) => {
|
addDomListener(actionElements.findNext, 'keyup', (e) => {
|
||||||
const searchOptions = getSearchOptions();
|
searchAddon.findNext(actionElements.findNext.value, getSearchOptions(e));
|
||||||
searchOptions.incremental = e.key !== `Enter`;
|
|
||||||
searchAddon.findNext(actionElements.findNext.value, searchOptions);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
addDomListener(actionElements.findPrevious, 'keyup', (e) => {
|
addDomListener(actionElements.findPrevious, 'keyup', (e) => {
|
||||||
if (e.key === `Enter`) {
|
searchAddon.findPrevious(actionElements.findPrevious.value, getSearchOptions(e));
|
||||||
searchAddon.findPrevious(actionElements.findPrevious.value, getSearchOptions());
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// fit is called within a setTimeout, cols and rows need this.
|
// fit is called within a setTimeout, cols and rows need this.
|
||||||
|
|||||||
Reference in New Issue
Block a user