From 44035d14ab12bb5661db711593745481baedc969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Breitbart?= Date: Fri, 5 Jul 2019 00:56:57 +0200 Subject: [PATCH] fix no wraparound mode --- fixtures/escape_sequence_files/t0102-DECAWM.text | 2 +- src/InputHandler.ts | 4 ++-- src/Terminal.test.ts | 9 +++++++-- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/fixtures/escape_sequence_files/t0102-DECAWM.text b/fixtures/escape_sequence_files/t0102-DECAWM.text index c1f22de2..6621f2b8 100644 --- a/fixtures/escape_sequence_files/t0102-DECAWM.text +++ b/fixtures/escape_sequence_files/t0102-DECAWM.text @@ -2,7 +2,7 @@ efgh -------- set: wraparound ----------------------------------------------abcd efgh --------- unset: no wraparound -------------------------------------------abcd +-------- unset: no wraparound -------------------------------------------abch this should be immediately below "no wraparound" diff --git a/src/InputHandler.ts b/src/InputHandler.ts index 754cc4a0..f97e4ba3 100644 --- a/src/InputHandler.ts +++ b/src/InputHandler.ts @@ -431,12 +431,12 @@ export class InputHandler extends Disposable implements IInputHandler { // row changed, get it again bufferRow = buffer.lines.get(buffer.y + buffer.ybase); } else { + buffer.x = cols - 1; if (chWidth === 2) { // FIXME: check for xterm behavior // What to do here? We got a wide char that does not fit into last cell continue; } - // FIXME: Do we have to set buffer.x to cols - 1, if not wrapping? } } @@ -2119,7 +2119,7 @@ export class InputHandler extends Disposable implements IInputHandler { this.cursorPosition([1, 1]); for (let yOffset = 0; yOffset < this._terminal.rows; ++yOffset) { - let row = buffer.y + buffer.ybase + yOffset; + const row = buffer.y + buffer.ybase + yOffset; buffer.lines.get(row).fill(cell); buffer.lines.get(row).isWrapped = false; } diff --git a/src/Terminal.test.ts b/src/Terminal.test.ts index f50b32a7..dad8d46a 100644 --- a/src/Terminal.test.ts +++ b/src/Terminal.test.ts @@ -8,6 +8,7 @@ import { Terminal } from './Terminal'; import { MockViewport, MockCompositionHelper, MockRenderer } from './TestUtils.test'; import { DEFAULT_ATTR_DATA } from 'common/buffer/BufferLine'; import { CellData } from 'common/buffer/CellData'; +import { wcwidth } from 'common/CharWidth'; const INIT_COLS = 80; const INIT_ROWS = 24; @@ -750,10 +751,14 @@ describe('Terminal', () => { for (let i = 0xDC00; i <= 0xDCFF; ++i) { term.buffer.x = term.cols - 1; term.wraparoundMode = false; + const width = wcwidth((0xD800 - 0xD800) * 0x400 + i - 0xDC00 + 0x10000); + if (width !== 1) { + continue; + } term.write('a' + high + String.fromCharCode(i)); // auto wraparound mode should cut off the rest of the line - expect(term.buffer.lines.get(0).loadCell(term.cols - 1, cell).getChars()).eql('a'); - expect(term.buffer.lines.get(0).loadCell(term.cols - 1, cell).getChars().length).eql(1); + expect(term.buffer.lines.get(0).loadCell(term.cols - 1, cell).getChars()).eql(high + String.fromCharCode(i)); + expect(term.buffer.lines.get(0).loadCell(term.cols - 1, cell).getChars().length).eql(2); expect(term.buffer.lines.get(1).loadCell(1, cell).getChars()).eql(''); term.reset(); }