Skip to content

Commit 45fe24d

Browse files
committed
Make ctrl+right in accessibility mode to jump to beginning of the word
1 parent ecefeb8 commit 45fe24d

2 files changed

Lines changed: 12 additions & 3 deletions

File tree

src/vs/editor/common/controller/cursorWordOperations.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,17 +289,26 @@ export class WordOperations {
289289
column = model.getLineMaxColumn(lineNumber);
290290
}
291291
} else if (wordNavigationType === WordNavigationType.WordAccessibility) {
292+
if (movedDown) {
293+
// If we move to the next line, pretend that the cursor is right before the first character.
294+
// This is needed when the first word starts right at the first character - and in order not to miss it,
295+
// we need to start before.
296+
column = 0;
297+
}
292298

293299
while (
294300
nextWordOnLine
295-
&& nextWordOnLine.wordType === WordType.Separator
301+
&& (nextWordOnLine.wordType === WordType.Separator
302+
|| nextWordOnLine.start + 1 <= column
303+
)
296304
) {
297305
// Skip over a word made up of one single separator
306+
// Also skip over word if it begins before current cursor position to ascertain we're moving forward at least 1 character.
298307
nextWordOnLine = WordOperations._findNextWordOnLine(wordSeparators, model, new Position(lineNumber, nextWordOnLine.end + 1));
299308
}
300309

301310
if (nextWordOnLine) {
302-
column = nextWordOnLine.end + 1;
311+
column = nextWordOnLine.start + 1;
303312
} else {
304313
column = model.getLineMaxColumn(lineNumber);
305314
}

src/vs/editor/contrib/wordOperations/test/wordOperations.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ suite('WordOperations', () => {
351351
});
352352

353353
test('cursorWordAccessibilityRight', () => {
354-
const EXPECTED = [' /* Just| some| more| text| a|+= 3| +5|-3| + 7| */ |'].join('\n');
354+
const EXPECTED = [' /* |Just |some |more |text |a+= |3 +|5-|3 + |7 */ |'].join('\n');
355355
const [text,] = deserializePipePositions(EXPECTED);
356356
const actualStops = testRepeatedActionAndExtractPositions(
357357
text,

0 commit comments

Comments
 (0)