mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
keep old impl in test as reference; minor changes
This commit is contained in:
@@ -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}`);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user