From c1a6bc16b83b7ad675a74c6267d8123a33200629 Mon Sep 17 00:00:00 2001 From: Connor Peet Date: Mon, 2 Nov 2020 10:51:35 -0800 Subject: [PATCH] terminal: capture cursor position correctly in typeahead backspace --- .../contrib/terminal/browser/terminalTypeAheadAddon.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/contrib/terminal/browser/terminalTypeAheadAddon.ts b/src/vs/workbench/contrib/terminal/browser/terminalTypeAheadAddon.ts index 5e15cd18e0e..edc9a75473b 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalTypeAheadAddon.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalTypeAheadAddon.ts @@ -415,12 +415,13 @@ class BackspacePrediction implements IPrediction { public apply(_: IBuffer, cursor: Cursor) { // at eol if everything to the right is whitespace (zsh will emit a "clear line" code in this case) // todo: can be optimized if `getTrimmedLength` is exposed from xterm - const eol = !cursor.getLine()?.translateToString(true, cursor.x); + const eol = !cursor.getLine()?.translateToString(undefined, cursor.x).trim(); + const pos = cursor.coordinate; const move = cursor.shift(-1); const cell = cursor.getCell(); this.appliedAt = cell - ? { eol, pos: cursor.coordinate, oldAttributes: attributesToSeq(cell), oldChar: cell.getChars() } - : { eol, pos: cursor.coordinate, oldAttributes: '', oldChar: '' }; + ? { eol, pos, oldAttributes: attributesToSeq(cell), oldChar: cell.getChars() } + : { eol, pos, oldAttributes: '', oldChar: '' }; return move + DELETE_CHAR; } -- GitLab