From c82868d09d74c8a0cc8e43e22b1a93531f419c5e Mon Sep 17 00:00:00 2001 From: Alex Dima Date: Mon, 14 Mar 2016 21:35:16 +0100 Subject: [PATCH] Fixes #3882: Ctrl+Delete removing entire line when used at the end of line --- src/vs/editor/common/controller/oneCursor.ts | 2 +- .../test/common/controller/cursor.test.ts | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/vs/editor/common/controller/oneCursor.ts b/src/vs/editor/common/controller/oneCursor.ts index 08801e76ef2..f41e375b6fe 100644 --- a/src/vs/editor/common/controller/oneCursor.ts +++ b/src/vs/editor/common/controller/oneCursor.ts @@ -1759,7 +1759,7 @@ export class OneCursorOp { if (nextWordOnLine) { column = nextWordOnLine.end + 1; } else { - column = 1; + column = maxColumn; } var deleteSelection = new Range(lineNumber, column, lineNumber, position.column); diff --git a/src/vs/editor/test/common/controller/cursor.test.ts b/src/vs/editor/test/common/controller/cursor.test.ts index 5c52a609617..6d13711036e 100644 --- a/src/vs/editor/test/common/controller/cursor.test.ts +++ b/src/vs/editor/test/common/controller/cursor.test.ts @@ -1347,6 +1347,30 @@ suite('Editor Controller - Regression tests', () => { assertWordRight(50, ' /* Just some more text a+= 3 +5-3 + 7 */ '.length + 1); }); }); + + test('issue #3882 (1): Ctrl+Delete removing entire line when used at the end of line', () => { + usingCursor({ + text: [ + 'A line with text.', + ' And another one' + ], + }, (model, cursor) => { + moveTo(cursor, 1, 18, false); + deleteWordRight(cursor); assert.equal(model.getLineContent(1), 'A line with text. And another one', '001'); + }); + }); + + test('issue #3882 (2): Ctrl+Delete removing entire line when used at the end of line', () => { + usingCursor({ + text: [ + 'A line with text.', + ' And another one' + ], + }, (model, cursor) => { + moveTo(cursor, 2, 1, false); + deleteWordLeft(cursor); assert.equal(model.getLineContent(1), 'A line with text. And another one', '001'); + }); + }); }); suite('Editor Controller - Cursor Configuration', () => { -- GitLab