Skip to content

Commit

Permalink
Fixes #101243
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdima committed Jun 28, 2020
1 parent 7798680 commit 7923112
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
13 changes: 0 additions & 13 deletions src/vs/editor/common/controller/cursorWordOperations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,9 @@ export class WordOperations {
public static moveWordLeft(wordSeparators: WordCharacterClassifier, model: ICursorSimpleModel, position: Position, wordNavigationType: WordNavigationType): Position {
let lineNumber = position.lineNumber;
let column = position.column;
let movedToPreviousLine = false;

if (column === 1) {
if (lineNumber > 1) {
movedToPreviousLine = true;
lineNumber = lineNumber - 1;
column = model.getLineMaxColumn(lineNumber);
}
Expand All @@ -176,17 +174,6 @@ export class WordOperations {
let prevWordOnLine = WordOperations._findPreviousWordOnLine(wordSeparators, model, new Position(lineNumber, column));

if (wordNavigationType === WordNavigationType.WordStart) {

if (prevWordOnLine && !movedToPreviousLine) {
// Special case for Visual Studio compatibility:
// when starting in the trim whitespace at the end of a line,
// go to the end of the last word
const lastWhitespaceColumn = model.getLineLastNonWhitespaceColumn(lineNumber);
if (lastWhitespaceColumn < column) {
return new Position(lineNumber, prevWordOnLine.end + 1);
}
}

return new Position(lineNumber, prevWordOnLine ? prevWordOnLine.start + 1 : 1);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ suite('WordOperations', () => {

test('cursorWordStartLeft', () => {
// This is the behaviour observed in Visual Studio, please do not touch test
const EXPECTED = ['| |/* |Just |some |more |text |a|+= |3 |+|5|-|3 |+ |7 |*/| '].join('\n');
const EXPECTED = ['| |/* |Just |some |more |text |a|+= |3 |+|5|-|3 |+ |7 |*/ '].join('\n');
const [text,] = deserializePipePositions(EXPECTED);
const actualStops = testRepeatedActionAndExtractPositions(
text,
Expand Down

0 comments on commit 7923112

Please sign in to comment.