diff --git a/src/vs/editor/common/controller/cursorWordOperations.ts b/src/vs/editor/common/controller/cursorWordOperations.ts index 300174e613aa8..84a9dcd96d29d 100644 --- a/src/vs/editor/common/controller/cursorWordOperations.ts +++ b/src/vs/editor/common/controller/cursorWordOperations.ts @@ -289,17 +289,26 @@ export class WordOperations { column = model.getLineMaxColumn(lineNumber); } } else if (wordNavigationType === WordNavigationType.WordAccessibility) { + if (movedDown) { + // If we move to the next line, pretend that the cursor is right before the first character. + // This is needed when the first word starts right at the first character - and in order not to miss it, + // we need to start before. + column = 0; + } while ( nextWordOnLine - && nextWordOnLine.wordType === WordType.Separator + && (nextWordOnLine.wordType === WordType.Separator + || nextWordOnLine.start + 1 <= column + ) ) { // Skip over a word made up of one single separator + // Also skip over word if it begins before current cursor position to ascertain we're moving forward at least 1 character. nextWordOnLine = WordOperations._findNextWordOnLine(wordSeparators, model, new Position(lineNumber, nextWordOnLine.end + 1)); } if (nextWordOnLine) { - column = nextWordOnLine.end + 1; + column = nextWordOnLine.start + 1; } else { column = model.getLineMaxColumn(lineNumber); } diff --git a/src/vs/editor/contrib/wordOperations/test/wordOperations.test.ts b/src/vs/editor/contrib/wordOperations/test/wordOperations.test.ts index baacaf2b44588..0fa9fe4caa791 100644 --- a/src/vs/editor/contrib/wordOperations/test/wordOperations.test.ts +++ b/src/vs/editor/contrib/wordOperations/test/wordOperations.test.ts @@ -351,7 +351,7 @@ suite('WordOperations', () => { }); test('cursorWordAccessibilityRight', () => { - 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,