mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Added another test case and fixed the multi-line issue that uncovered
This commit is contained in:
+1
-6
@@ -274,13 +274,8 @@ export class Buffer implements IBuffer {
|
||||
* @param trimRight Whether to trim whitespace to the right.
|
||||
*/
|
||||
public translateBufferLineToStringWithWrap(lineIndex: number, trimRight: boolean): string {
|
||||
// Get full line
|
||||
let lineString = '';
|
||||
let lineWrapsToNext = true;
|
||||
if (this.lines.get(lineIndex).isWrapped) {
|
||||
// This terminal line is a continuation of the previous line.
|
||||
return '';
|
||||
}
|
||||
let lineWrapsToNext: boolean;
|
||||
|
||||
do {
|
||||
lineString += this.translateBufferLineToString(lineIndex, true);
|
||||
|
||||
@@ -120,8 +120,9 @@ export class SearchHelper implements ISearchHelper {
|
||||
} else {
|
||||
searchIndex = lowerStringLine.indexOf(lowerTerm);
|
||||
}
|
||||
if (searchIndex >= 0) {
|
||||
const line = this._terminal._core.buffer.lines.get(y);
|
||||
|
||||
const line = this._terminal._core.buffer.lines.get(y);
|
||||
if ((searchIndex >= 0) && (searchIndex < line.length)) {
|
||||
for (let i = 0; i < searchIndex; i++) {
|
||||
const charData = line.get(i);
|
||||
// Adjust the searchIndex to normalize emoji into single chars
|
||||
|
||||
@@ -55,13 +55,19 @@ describe('search addon', function(): void {
|
||||
});
|
||||
it('should find search term accross line wrap', function(): void {
|
||||
search.apply(<any>MockTerminal);
|
||||
const term = new MockTerminal({cols: 10, rows: 2});
|
||||
term.core.write('texttextHellotext');
|
||||
const term = new MockTerminal({cols: 10, rows: 5});
|
||||
term.core.write('texttextHellotext\r\n');
|
||||
term.core.write('texttexttextHellotext');
|
||||
term.pushWriteData();
|
||||
|
||||
const hello0 = (term.searchHelper as any)._findInLine('Hello', 0);
|
||||
const hello1 = (term.searchHelper as any)._findInLine('Hello', 1);
|
||||
const hello2 = (term.searchHelper as any)._findInLine('Hello', 2);
|
||||
const hello3 = (term.searchHelper as any)._findInLine('Hello', 3);
|
||||
expect(hello0).eql({col: 8, row: 0, term: 'Hello'});
|
||||
expect(hello1).eql(undefined);
|
||||
expect(hello2).eql(undefined);
|
||||
expect(hello3).eql({col: 2, row: 3, term: 'Hello'});
|
||||
});
|
||||
it('should respect search regex', function(): void {
|
||||
search.apply(<any>MockTerminal);
|
||||
|
||||
Reference in New Issue
Block a user