Discard cut off combined data when resizing BufferLines
This commit is contained in:
@@ -9,6 +9,10 @@ import { NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE, DEFAULT_ATTR } from '.
|
|||||||
|
|
||||||
|
|
||||||
class TestBufferLine extends BufferLine {
|
class TestBufferLine extends BufferLine {
|
||||||
|
public get combined(): {[index: number]: string} {
|
||||||
|
return this._combined;
|
||||||
|
}
|
||||||
|
|
||||||
public toArray(): CharData[] {
|
public toArray(): CharData[] {
|
||||||
const result = [];
|
const result = [];
|
||||||
for (let i = 0; i < this.length; ++i) {
|
for (let i = 0; i < this.length; ++i) {
|
||||||
@@ -154,6 +158,15 @@ describe('BufferLine', function(): void {
|
|||||||
line.resize(0, [1, 'a', 0, 'a'.charCodeAt(0)]);
|
line.resize(0, [1, 'a', 0, 'a'.charCodeAt(0)]);
|
||||||
chai.expect(line.toArray()).eql(Array(0).fill([1, 'a', 0, 'a'.charCodeAt(0)]));
|
chai.expect(line.toArray()).eql(Array(0).fill([1, 'a', 0, 'a'.charCodeAt(0)]));
|
||||||
});
|
});
|
||||||
|
it('should remove combining data', () => {
|
||||||
|
const line = new TestBufferLine(10, [1, 'a', 0, 'a'.charCodeAt(0)], false);
|
||||||
|
line.set(9, [ null, '😁', 1, '😁'.charCodeAt(0) ]);
|
||||||
|
chai.expect(line.translateToString()).eql('aaaaaaaaa😁');
|
||||||
|
chai.expect(Object.keys(line.combined).length).eql(1);
|
||||||
|
line.resize(5, [1, 'a', 0, 'a'.charCodeAt(0)]);
|
||||||
|
chai.expect(line.translateToString()).eql('aaaaa');
|
||||||
|
chai.expect(Object.keys(line.combined).length).eql(0);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
describe('getTrimLength', function(): void {
|
describe('getTrimLength', function(): void {
|
||||||
it('empty line', function(): void {
|
it('empty line', function(): void {
|
||||||
|
|||||||
@@ -250,8 +250,17 @@ export class BufferLine implements IBufferLine {
|
|||||||
const data = new Uint32Array(cols * CELL_SIZE);
|
const data = new Uint32Array(cols * CELL_SIZE);
|
||||||
data.set(this._data.subarray(0, cols * CELL_SIZE));
|
data.set(this._data.subarray(0, cols * CELL_SIZE));
|
||||||
this._data = data;
|
this._data = data;
|
||||||
|
// Remove any cut off combined data
|
||||||
|
const keys = Object.keys(this._combined);
|
||||||
|
for (let i = 0; i < keys.length; i++) {
|
||||||
|
const key = parseInt(keys[i], 10);
|
||||||
|
if (key >= cols) {
|
||||||
|
delete this._combined[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this._data = null;
|
this._data = null;
|
||||||
|
this._combined = {};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.length = cols;
|
this.length = cols;
|
||||||
|
|||||||
Reference in New Issue
Block a user