Merge branch 'master' into event_emitter_2
This commit is contained in:
@@ -57,12 +57,27 @@ export class SearchHelper implements ISearchHelper {
|
|||||||
|
|
||||||
this._initLinesCache();
|
this._initLinesCache();
|
||||||
|
|
||||||
|
// A row that has isWrapped = false
|
||||||
|
let findingRow = startRow;
|
||||||
|
// index of beginning column that _findInLine need to scan.
|
||||||
|
let cumulativeCols = startCol;
|
||||||
|
// If startRow is wrapped row, scan for unwrapped row above.
|
||||||
|
// So we can start matching on wrapped line from long unwrapped line.
|
||||||
|
while (this._terminal._core.buffer.lines.get(findingRow).isWrapped) {
|
||||||
|
findingRow--;
|
||||||
|
cumulativeCols += this._terminal.cols;
|
||||||
|
}
|
||||||
|
|
||||||
// Search startRow
|
// Search startRow
|
||||||
result = this._findInLine(term, startRow, startCol, searchOptions);
|
result = this._findInLine(term, findingRow, cumulativeCols, searchOptions);
|
||||||
|
|
||||||
// Search from startRow + 1 to end
|
// Search from startRow + 1 to end
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
|
||||||
for (let y = startRow + 1; y < this._terminal._core.buffer.ybase + this._terminal.rows; y++) {
|
for (let y = startRow + 1; y < this._terminal._core.buffer.ybase + this._terminal.rows; y++) {
|
||||||
|
|
||||||
|
// 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
|
||||||
result = this._findInLine(term, y, 0, searchOptions);
|
result = this._findInLine(term, y, 0, searchOptions);
|
||||||
if (result) {
|
if (result) {
|
||||||
break;
|
break;
|
||||||
@@ -73,7 +88,7 @@ export class SearchHelper implements ISearchHelper {
|
|||||||
// Search from the top to the startRow (search the whole startRow again in
|
// Search from the top to the startRow (search the whole startRow again in
|
||||||
// case startCol > 0)
|
// case startCol > 0)
|
||||||
if (!result) {
|
if (!result) {
|
||||||
for (let y = 0; y <= startRow; y++) {
|
for (let y = 0; y < findingRow; y++) {
|
||||||
result = this._findInLine(term, y, 0, searchOptions);
|
result = this._findInLine(term, y, 0, searchOptions);
|
||||||
if (result) {
|
if (result) {
|
||||||
break;
|
break;
|
||||||
@@ -102,8 +117,8 @@ export class SearchHelper implements ISearchHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const isReverseSearch = true;
|
const isReverseSearch = true;
|
||||||
let startRow = this._terminal._core.buffer.ydisp;
|
let startRow = this._terminal._core.buffer.ydisp + this._terminal.rows - 1;
|
||||||
let startCol: number = this._terminal._core.buffer.lines.get(startRow).length;
|
let startCol = this._terminal.cols;
|
||||||
|
|
||||||
if (selectionManager.selectionStart) {
|
if (selectionManager.selectionStart) {
|
||||||
// Start from the selection start if there is a selection
|
// Start from the selection start if there is a selection
|
||||||
@@ -120,11 +135,24 @@ export class SearchHelper implements ISearchHelper {
|
|||||||
|
|
||||||
// Search from startRow - 1 to top
|
// Search from startRow - 1 to top
|
||||||
if (!result) {
|
if (!result) {
|
||||||
|
// If the line is wrapped line, increase number of columns that is needed to be scanned
|
||||||
|
// Se we can scan on wrapped line from unwrapped line
|
||||||
|
let cumulativeCols = this._terminal.cols;
|
||||||
|
if (this._terminal._core.buffer.lines.get(startRow).isWrapped) {
|
||||||
|
cumulativeCols += startCol;
|
||||||
|
}
|
||||||
for (let y = startRow - 1; y >= 0; y--) {
|
for (let y = startRow - 1; y >= 0; y--) {
|
||||||
result = this._findInLine(term, y, this._terminal._core.buffer.lines.get(y).length, searchOptions, isReverseSearch);
|
result = this._findInLine(term, y, cumulativeCols, searchOptions, isReverseSearch);
|
||||||
if (result) {
|
if (result) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// If the current line is wrapped line, increase scanning range,
|
||||||
|
// preparing for scanning on unwrapped line
|
||||||
|
if (this._terminal._core.buffer.lines.get(y).isWrapped) {
|
||||||
|
cumulativeCols += this._terminal.cols;
|
||||||
|
} else {
|
||||||
|
cumulativeCols = this._terminal.cols;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,11 +160,17 @@ export class SearchHelper implements ISearchHelper {
|
|||||||
// case startCol > 0)
|
// case startCol > 0)
|
||||||
if (!result) {
|
if (!result) {
|
||||||
const searchFrom = this._terminal._core.buffer.ybase + this._terminal.rows - 1;
|
const searchFrom = this._terminal._core.buffer.ybase + this._terminal.rows - 1;
|
||||||
|
let cumulativeCols = this._terminal.cols;
|
||||||
for (let y = searchFrom; y >= startRow; y--) {
|
for (let y = searchFrom; y >= startRow; y--) {
|
||||||
result = this._findInLine(term, y, this._terminal._core.buffer.lines.get(y).length, searchOptions, isReverseSearch);
|
result = this._findInLine(term, y, cumulativeCols, searchOptions, isReverseSearch);
|
||||||
if (result) {
|
if (result) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (this._terminal._core.buffer.lines.get(y).isWrapped) {
|
||||||
|
cumulativeCols += this._terminal.cols;
|
||||||
|
} else {
|
||||||
|
cumulativeCols = this._terminal.cols;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,10 +226,11 @@ export class SearchHelper implements ISearchHelper {
|
|||||||
* @return The search result if it was found.
|
* @return The search result if it was found.
|
||||||
*/
|
*/
|
||||||
protected _findInLine(term: string, row: number, col: number, searchOptions: ISearchOptions = {}, isReverseSearch: boolean = false): ISearchResult {
|
protected _findInLine(term: string, row: number, col: number, searchOptions: ISearchOptions = {}, isReverseSearch: boolean = false): ISearchResult {
|
||||||
|
|
||||||
|
// Ignore wrapped lines, only consider on unwrapped line (first row of command string).
|
||||||
if (this._terminal._core.buffer.lines.get(row).isWrapped) {
|
if (this._terminal._core.buffer.lines.get(row).isWrapped) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let stringLine = this._linesCache ? this._linesCache[row] : void 0;
|
let stringLine = this._linesCache ? this._linesCache[row] : void 0;
|
||||||
if (stringLine === void 0) {
|
if (stringLine === void 0) {
|
||||||
stringLine = this.translateBufferLineToStringWithWrap(row, true);
|
stringLine = this.translateBufferLineToStringWithWrap(row, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user