From 4a9f10d062c2f92b08dbbc862e7a5279ed5f2a3e Mon Sep 17 00:00:00 2001 From: Daniel Imms Date: Fri, 28 Dec 2018 19:22:05 -0800 Subject: [PATCH] Remove some of Buffer's dependency on Terminal --- src/Buffer.test.ts | 9 ++------- src/Buffer.ts | 4 ++-- src/Types.ts | 1 - 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/Buffer.test.ts b/src/Buffer.test.ts index 189b3ad6..cee0fbad 100644 --- a/src/Buffer.test.ts +++ b/src/Buffer.test.ts @@ -108,12 +108,12 @@ describe('Buffer', () => { describe('resize', () => { describe('column size is reduced', () => { - it('should not trim the data in the buffer', () => { + it('should trim the data in the buffer', () => { buffer.fillViewportRows(); buffer.resize(INIT_COLS / 2, INIT_ROWS); assert.equal(buffer.lines.length, INIT_ROWS); for (let i = 0; i < INIT_ROWS; i++) { - assert.equal(buffer.lines.get(i).length, INIT_COLS); + assert.equal(buffer.lines.get(i).length, INIT_COLS / 2); } }); }); @@ -235,11 +235,6 @@ describe('Buffer', () => { }); describe('reflow', () => { - beforeEach(() => { - terminal.eraseAttr = () => DEFAULT_ATTR; - // Needed until the setting is removed - terminal.options.experimentalBufferLineImpl = 'TypedArray'; - }); it('should not wrap empty lines', () => { buffer.fillViewportRows(); assert.equal(buffer.lines.length, INIT_ROWS); diff --git a/src/Buffer.ts b/src/Buffer.ts index 0b660321..feb3a1ee 100644 --- a/src/Buffer.ts +++ b/src/Buffer.ts @@ -234,7 +234,7 @@ export class Buffer implements IBuffer { this.scrollBottom = newRows - 1; - if (this.hasScrollback && this._terminal.options.experimentalBufferLineImpl === 'TypedArray') { + if (this.hasScrollback && this._bufferLineConstructor === BufferLine) { this._reflow(newCols); // Trim the end of the line off if cols shrunk @@ -374,7 +374,7 @@ export class Buffer implements IBuffer { // Add the new lines const newLines: BufferLine[] = []; for (let i = 0; i < linesToAdd; i++) { - const newLine = this.getBlankLine(this._terminal.eraseAttr(), true) as BufferLine; + const newLine = this.getBlankLine(DEFAULT_ATTR, true) as BufferLine; newLines.push(newLine); } this.lines.splice(y + wrappedLines.length, 0, ...newLines); diff --git a/src/Types.ts b/src/Types.ts index d7715f81..d48362b8 100644 --- a/src/Types.ts +++ b/src/Types.ts @@ -230,7 +230,6 @@ export interface ITerminal extends PublicTerminal, IElementAccessor, IBufferAcce cancel(ev: Event, force?: boolean): boolean | void; log(text: string): void; showCursor(): void; - eraseAttr(): number; } export interface IBufferAccessor {