Added another test case and fixed the multi-line issue that uncovered

This commit is contained in:
Alex Ross
2018-09-10 10:22:12 -07:00
parent bc156294aa
commit 1460a34796
3 changed files with 12 additions and 10 deletions
+3 -2
View File
@@ -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
+8 -2
View File
@@ -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);