From 8979eea810400cdfc32ad08265a0ae31b554aed9 Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Tue, 11 Sep 2018 16:12:53 -0700 Subject: [PATCH 1/2] Fixed translateBufferLineToStringWithWrap to correctly not remove spaces in the middle of a multiline wrapped string --- src/addons/search/SearchHelper.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/addons/search/SearchHelper.ts b/src/addons/search/SearchHelper.ts index 4cc13e632e..051fa0475b 100644 --- a/src/addons/search/SearchHelper.ts +++ b/src/addons/search/SearchHelper.ts @@ -170,10 +170,10 @@ export class SearchHelper implements ISearchHelper { let lineWrapsToNext: boolean; do { - lineString += this._terminal._core.buffer.translateBufferLineToString(lineIndex, true); - lineIndex++; const nextLine = this._terminal._core.buffer.lines.get(lineIndex); - lineWrapsToNext = nextLine ? this._terminal._core.buffer.lines.get(lineIndex).isWrapped : false; + lineWrapsToNext = nextLine ? nextLine.isWrapped : false; + lineString += this._terminal._core.buffer.translateBufferLineToString(lineIndex, !lineWrapsToNext && trimRight); + lineIndex++; } while (lineWrapsToNext); return lineString; From 5aa665697151aba3c99d5ee857046bcc7ff6f400 Mon Sep 17 00:00:00 2001 From: Alex Ross Date: Tue, 11 Sep 2018 16:27:22 -0700 Subject: [PATCH 2/2] Added test and fixed uncovered buy --- src/addons/search/SearchHelper.ts | 2 +- src/addons/search/search.test.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/addons/search/SearchHelper.ts b/src/addons/search/SearchHelper.ts index 051fa0475b..2bf9647180 100644 --- a/src/addons/search/SearchHelper.ts +++ b/src/addons/search/SearchHelper.ts @@ -170,7 +170,7 @@ export class SearchHelper implements ISearchHelper { let lineWrapsToNext: boolean; do { - const nextLine = this._terminal._core.buffer.lines.get(lineIndex); + const nextLine = this._terminal._core.buffer.lines.get(lineIndex + 1); lineWrapsToNext = nextLine ? nextLine.isWrapped : false; lineString += this._terminal._core.buffer.translateBufferLineToString(lineIndex, !lineWrapsToNext && trimRight); lineIndex++; diff --git a/src/addons/search/search.test.ts b/src/addons/search/search.test.ts index 014b01d861..13138f07d6 100644 --- a/src/addons/search/search.test.ts +++ b/src/addons/search/search.test.ts @@ -59,14 +59,15 @@ describe('search addon', () => { search.apply(MockTerminal); const term = new MockTerminal({cols: 10, rows: 5}); term.core.write('texttextHellotext\r\n'); - term.core.write('texttexttextHellotext'); + term.core.write('texttexttextHellotext goodbye'); term.pushWriteData(); /* texttextHe llotext texttextte xtHellotex - t + t (these spaces included intentionally) + goodbye */ const hello0 = (term.searchHelper as any)._findInLine('Hello', 0); @@ -74,11 +75,13 @@ describe('search addon', () => { const hello2 = (term.searchHelper as any)._findInLine('Hello', 2); const hello3 = (term.searchHelper as any)._findInLine('Hello', 3); const llo = (term.searchHelper as any)._findInLine('llo', 1); + const goodbye = (term.searchHelper as any)._findInLine('goodbye', 2); expect(hello0).eql({col: 8, row: 0, term: 'Hello'}); expect(hello1).eql(undefined); expect(hello2).eql({col: 2, row: 3, term: 'Hello'}); expect(hello3).eql(undefined); expect(llo).eql(undefined); + expect(goodbye).eql({col: 0, row: 5, term: 'goodbye'}); }); it('should respect search regex', () => { search.apply(MockTerminal);