keep old impl in test as reference; minor changes

This commit is contained in:
Jörg Breitbart
2018-11-20 22:35:51 +01:00
parent 21f848d0ab
commit 36db03e713
3 changed files with 7 additions and 10 deletions
+6 -7
View File
@@ -78,8 +78,8 @@ describe('getStringCellWidth', function(): void {
// TODO: multiline tests once #1685 is resolved
});
describe('wcwidth regression', function(): void {
// TODO: remove with one of the next releases
it('wcwidth should match all values from the old implementation', function(): void {
// old implementation
const wcwidthOld = (function(opts: {nul: number, control: number}): (ucs: number) => number {
// extracted from https://www.cl.cam.ac.uk/%7Emgk25/ucs/wcwidth.c
// combining characters
@@ -247,9 +247,8 @@ describe('wcwidth regression', function(): void {
};
})({nul: 0, control: 0}); // configurable options
it('equality of old and new impl', function(): void {
for (let i = 0; i < 65536; ++i) {
assert.equal(wcwidth(i), wcwidthOld(i), `mismatch for i: ${i}`);
}
});
// test full BMP range old vs new implmenetation
for (let i = 0; i < 65536; ++i) {
assert.equal(wcwidth(i), wcwidthOld(i), `mismatch for i: ${i}`);
}
});
-1
View File
@@ -90,7 +90,6 @@ export const wcwidth = (function(opts: {nul: number, control: number}): (ucs: nu
const control = opts.control | 0;
// create lookup table for BMP plane
// TODO: make callable/configurable from UnicodeManager
const table = new Uint8Array(65536);
table.fill(1);
table[0] = opts.nul;
+1 -2
View File
@@ -327,7 +327,6 @@ export class InputHandler extends Disposable implements IInputHandler {
public print(data: string, start: number, end: number): void {
let char: string;
let code: number;
let second: number;
let chWidth: number;
const buffer: IBuffer = this._terminal.buffer;
const charset: ICharset = this._terminal.charset;
@@ -355,7 +354,7 @@ export class InputHandler extends Disposable implements IInputHandler {
this._surrogateFirst = char;
continue;
}
second = data.charCodeAt(stringPosition);
const second = data.charCodeAt(stringPosition);
// if the second part is in surrogate pair range create the high codepoint
// otherwise fall back to UCS-2 behavior (handle codepoints independently)
if (0xDC00 <= second && second <= 0xDFFF) {