From f8e3fa5a994b8bfdd57529e2309cd726cca545c5 Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Tue, 18 Jul 2017 19:58:35 -0700 Subject: [PATCH] Fix browserify build and search addon (#804) Fixes #803 --- gulpfile.js | 6 ++++++ src/addons/search/SearchHelper.ts | 12 ++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index ef4e460..6e21102 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -22,6 +22,12 @@ let tsProjectSearchAddon = ts.createProject('./src/addons/search/tsconfig.json') let srcDir = tsProject.config.compilerOptions.rootDir; let outDir = tsProject.config.compilerOptions.outDir; +// Under some environments like TravisCI, this comes out at absolute which can +// break the build. This ensures that the outDir is absolute. +if (outDir.indexOf(__dirname) !== 0) { + outDir = `${__dirname}/${outDir}`; +} + /** * Compile TypeScript sources to JavaScript files and create a source map file for each TypeScript * file compiled. diff --git a/src/addons/search/SearchHelper.ts b/src/addons/search/SearchHelper.ts index f285144..43d6dc1 100644 --- a/src/addons/search/SearchHelper.ts +++ b/src/addons/search/SearchHelper.ts @@ -35,14 +35,14 @@ export class SearchHelper { let result: ISearchResult; - let startRow = this._terminal.ydisp; + let startRow = this._terminal.buffer.ydisp; if (this._terminal.selectionManager.selectionEnd) { // Start from the selection end if there is a selection startRow = this._terminal.selectionManager.selectionEnd[1]; } // Search from ydisp + 1 to end - for (let y = startRow + 1; y < this._terminal.ybase + this._terminal.rows; y++) { + for (let y = startRow + 1; y < this._terminal.buffer.ybase + this._terminal.rows; y++) { result = this._findInLine(term, y); if (result) { break; @@ -76,7 +76,7 @@ export class SearchHelper { let result: ISearchResult; - let startRow = this._terminal.ydisp; + let startRow = this._terminal.buffer.ydisp; if (this._terminal.selectionManager.selectionStart) { // Start from the selection end if there is a selection startRow = this._terminal.selectionManager.selectionStart[1]; @@ -92,7 +92,7 @@ export class SearchHelper { // Search from the top to the current ydisp if (!result) { - for (let y = this._terminal.ybase + this._terminal.rows - 1; y > startRow; y--) { + for (let y = this._terminal.buffer.ybase + this._terminal.rows - 1; y > startRow; y--) { result = this._findInLine(term, y); if (result) { break; @@ -111,7 +111,7 @@ export class SearchHelper { * @return The search result if it was found. */ private _findInLine(term: string, y: number): ISearchResult { - const bufferLine = this._terminal.lines.get(y); + const bufferLine = this._terminal.buffer.lines.get(y); const lowerStringLine = this._translateBufferLineToString(bufferLine, true).toLowerCase(); const lowerTerm = term.toLowerCase(); const searchIndex = lowerStringLine.indexOf(lowerTerm); @@ -134,7 +134,7 @@ export class SearchHelper { return false; } this._terminal.selectionManager.setSelection(result.col, result.row, result.term.length); - this._terminal.scrollDisp(result.row - this._terminal.ydisp, false); + this._terminal.scrollDisp(result.row - this._terminal.buffer.ydisp, false); return true; } } -- 2.39.2