_findInLine() function should not run multiple times on the same row

This commit is contained in:
ntchjb
2019-01-09 07:01:34 +07:00
parent 932d5c7c21
commit 9236934586
+3 -23
View File
@@ -76,15 +76,7 @@ export class SearchHelper implements ISearchHelper {
// If the current line is wrapped line, increase index of column to ignore the previous scan
// Otherwise, reset beginning column index to zero with set new unwrapped line index
if (this._terminal._core.buffer.lines.get(y).isWrapped) {
cumulativeCols += this._terminal.cols;
} else {
cumulativeCols = 0;
findingRow = y;
}
// Run _findInLine at unwrapped row, scan for cumulativeCols columns
result = this._findInLine(term, findingRow, cumulativeCols, searchOptions);
result = this._findInLine(term, y, 0, searchOptions);
if (result) {
break;
}
@@ -94,23 +86,11 @@ export class SearchHelper implements ISearchHelper {
// Search from the top to the startRow (search the whole startRow again in
// case startCol > 0)
if (!result) {
// Assume that The first line is always unwrapped line
let findingRow = 0;
// Scan at beginning of the line
let cumulativeCols = 0;
for (let y = 0; y <= startRow; y++) {
result = this._findInLine(term, findingRow, cumulativeCols, searchOptions);
for (let y = 0; y < findingRow; y++) {
result = this._findInLine(term, y, 0, searchOptions);
if (result) {
break;
}
// If the current line is wrapped line, increase index of beginning column
// So we ignore the previous scan
if (this._terminal._core.buffer.lines.get(y).isWrapped) {
cumulativeCols += this._terminal.cols;
} else {
cumulativeCols = 0;
findingRow = y;
}
}
}