Skip to content

Commit

Permalink
Fixes #24947: Ctrl - Backspace is deleting the previous '({['
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima committed Apr 27, 2017
1 parent db036ea commit c9313f7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 15 deletions.
18 changes: 4 additions & 14 deletions src/vs/editor/common/controller/cursorWordOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,16 +293,11 @@ export class WordOperations {
if (prevWordOnLine) {
column = prevWordOnLine.start + 1;
} else {
if (column > 1 || lineNumber === 1) {
if (column > 1) {
column = 1;
} else {
lineNumber--;
prevWordOnLine = WordOperations._findPreviousWordOnLine(wordSeparators, model, new Position(lineNumber, model.getLineMaxColumn(lineNumber)));
if (prevWordOnLine) {
column = prevWordOnLine.start + 1;
} else {
column = 1;
}
column = model.getLineMaxColumn(lineNumber);
}
}
} else {
Expand All @@ -312,16 +307,11 @@ export class WordOperations {
if (prevWordOnLine) {
column = prevWordOnLine.end + 1;
} else {
if (column > 1 || lineNumber === 1) {
if (column > 1) {
column = 1;
} else {
lineNumber--;
prevWordOnLine = WordOperations._findPreviousWordOnLine(wordSeparators, model, new Position(lineNumber, model.getLineMaxColumn(lineNumber)));
if (prevWordOnLine) {
column = prevWordOnLine.end + 1;
} else {
column = 1;
}
column = model.getLineMaxColumn(lineNumber);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,35 @@ suite('WordOperations', () => {
});
});

test('issue #24947', () => {
withMockCodeEditor([
'{',
'}'
], {}, (editor, _) => {
const model = editor.getModel();
editor.setPosition(new Position(2, 1));
deleteWordLeft(editor); assert.equal(model.getLineContent(1), '{}');
});

withMockCodeEditor([
'{',
'}'
], {}, (editor, _) => {
const model = editor.getModel();
editor.setPosition(new Position(2, 1));
deleteWordStartLeft(editor); assert.equal(model.getLineContent(1), '{}');
});

withMockCodeEditor([
'{',
'}'
], {}, (editor, _) => {
const model = editor.getModel();
editor.setPosition(new Position(2, 1));
deleteWordEndLeft(editor); assert.equal(model.getLineContent(1), '{}');
});
});

test('issue #832: deleteWordRight', () => {
withMockCodeEditor([
' /* Just some text a+= 3 +5-3 */ '
Expand Down Expand Up @@ -669,7 +698,7 @@ suite('WordOperations', () => {
], {}, (editor, _) => {
const model = editor.getModel();
editor.setPosition(new Position(2, 1));
deleteWordLeft(editor); assert.equal(model.getLineContent(1), 'A line with text And another one', '001');
deleteWordLeft(editor); assert.equal(model.getLineContent(1), 'A line with text. And another one', '001');
});
});
});

0 comments on commit c9313f7

Please sign in to comment.