fix buffer tests

This commit is contained in:
Jörg Breitbart
2018-10-31 15:11:18 +01:00
parent 1c111d3e60
commit 8ffcd65cff
3 changed files with 9 additions and 10 deletions
+3 -3
View File
@@ -509,10 +509,10 @@ describe('Buffer', () => {
// --> fixable after resolving #1685
terminal.writeSync(input);
// TODO: reenable after fix
// const s = terminal.buffer.contents(true).toArray()[0];
// assert.equal(input, s);
const s = terminal.buffer.iterator(true).next().content;
assert.equal(input, s);
for (let i = 10; i < input.length; ++i) {
const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i + 1); // TODO: remove +1 after fix
const bufferIndex = terminal.buffer.stringIndexToBufferIndex(0, i); // TODO: remove +1 after fix
const j = (i - 0) << 1;
assert.deepEqual([(j / terminal.cols) | 0, j % terminal.cols], bufferIndex);
}
+2 -3
View File
@@ -21,7 +21,7 @@ export const MAX_BUFFER_SIZE = 4294967295; // 2^32 - 1
// export const NULL_CELL_CODE = 32;
export const NULL_CELL_CHAR = '';
export const NULL_CELL_WIDTH = 0;
export const NULL_CELL_WIDTH = 1;
export const NULL_CELL_CODE = 0;
/**
@@ -488,8 +488,7 @@ export class BufferStringIterator implements IBufferStringIterator {
range.last = Math.min(range.last, this._buffer.lines.length);
let result = '';
for (let i = range.first; i <= range.last; ++i) {
// TODO: always apply trimRight after fixing #1685
result += this._buffer.translateBufferLineToString(i, (this._trimRight) ? i === range.last : false);
result += this._buffer.translateBufferLineToString(i, this._trimRight);
}
this._current = range.last + 1;
return {range: range, content: result};
+4 -4
View File
@@ -113,7 +113,7 @@ export class BufferLine implements IBufferLine {
for (let i = this.length - 1; i >= 0; --i) {
const ch = this.get(i);
if (ch[CHAR_DATA_CHAR_INDEX] !== '') {
return i + ch[CHAR_DATA_WIDTH_INDEX] - 1;
return i + ch[CHAR_DATA_WIDTH_INDEX];
}
}
return 0;
@@ -124,7 +124,7 @@ export class BufferLine implements IBufferLine {
if (trimRight)
length = Math.min(length, this.getTrimmedLength());
let result = '';
while (startCol < endCol) {
while (startCol < length) {
result += this.get(startCol)[CHAR_DATA_CHAR_INDEX] || ' ';
startCol += this.get(startCol)[CHAR_DATA_WIDTH_INDEX] || 1;
}
@@ -305,7 +305,7 @@ export class BufferLineTypedArray implements IBufferLine {
public getTrimmedLength(): number {
for (let i = this.length - 1; i >= 0; --i) {
if (this._data[i * CELL_SIZE + Cell.STRING] !== 0) { // 0 ==> ''.charCodeAt(0) ==> NaN ==> 0
return i + this._data[i * CELL_SIZE + Cell.WIDTH] - 1;
return i + this._data[i * CELL_SIZE + Cell.WIDTH];
}
}
return 0;
@@ -316,7 +316,7 @@ export class BufferLineTypedArray implements IBufferLine {
if (trimRight)
length = Math.min(length, this.getTrimmedLength());
let result = '';
while (startCol < endCol) {
while (startCol < length) {
const stringData = this._data[startCol * CELL_SIZE + Cell.STRING];
result += (stringData & 0x80000000) ? this._combined[startCol] : (stringData) ? String.fromCharCode(stringData) : ' ';
startCol += this._data[startCol * CELL_SIZE + Cell.WIDTH] || 1;