Skip to content

Commit 0c90b53

Browse files
committed
1 parent 317a466 commit 0c90b53

3 files changed

Lines changed: 31 additions & 3 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1273,7 +1273,8 @@ export namespace CoreNavigationCommands {
12731273
const lastAddedCursorIndex = cursors.getLastAddedCursorIndex();
12741274

12751275
let newStates = cursors.getAll().slice(0);
1276-
newStates[lastAddedCursorIndex] = CursorMoveCommands.word(context, newStates[lastAddedCursorIndex], true, args.position);
1276+
let lastAddedState = newStates[lastAddedCursorIndex];
1277+
newStates[lastAddedCursorIndex] = CursorMoveCommands.word(context, lastAddedState, lastAddedState.modelState.hasSelection(), args.position);
12771278

12781279
context.model.pushStackElement();
12791280
cursors.setStates(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ export class WordOperations {
378378
let nextWord = WordOperations._findNextWordOnLine(wordSeparators, model, position);
379379
let isInNextWord = (nextWord && nextWord.wordType === WordType.Regular && nextWord.start < position.column - 1 && position.column - 1 <= nextWord.end);
380380

381-
if (!inSelectionMode || !cursor.hasSelection()) {
381+
if (!inSelectionMode) {
382382
// Entering word selection for the first time
383383

384384
let startColumn: number;
@@ -439,6 +439,6 @@ export class WordOperations {
439439
}
440440
}
441441

442-
return cursor.move(cursor.hasSelection(), lineNumber, column, 0);
442+
return cursor.move(true, lineNumber, column, 0);
443443
}
444444
}

src/vs/editor/test/common/controller/cursor.test.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3699,4 +3699,31 @@ suite('autoClosingPairs', () => {
36993699
model.dispose();
37003700
mode.dispose();
37013701
});
3702+
3703+
test('issue #7100: Mouse word selection is strange when non-word character is at the end of line', () => {
3704+
let model = Model.createFromString(
3705+
[
3706+
'before.a',
3707+
'before',
3708+
'hello:',
3709+
'there:',
3710+
'this is strange:',
3711+
'here',
3712+
'it',
3713+
'is',
3714+
].join('\n')
3715+
);
3716+
3717+
withMockCodeEditor(null, { model: model }, (editor, cursor) => {
3718+
CoreNavigationCommands.WordSelect.runEditorCommand(null, editor, {
3719+
position: new Position(3, 7)
3720+
});
3721+
assertCursor(cursor, new Selection(3, 7, 3, 7));
3722+
3723+
CoreNavigationCommands.WordSelectDrag.runEditorCommand(null, editor, {
3724+
position: new Position(4, 7)
3725+
});
3726+
assertCursor(cursor, new Selection(3, 7, 4, 7));
3727+
});
3728+
});
37023729
});

0 commit comments

Comments
 (0)