Skip to content

Commit a52d749

Browse files
committed
Fix r in Visual mode with multiple cursors
1 parent dd63769 commit a52d749

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

src/actions/commands/actions.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,9 +1363,6 @@ export class ActionReplaceCharacter extends BaseCommand {
13631363
class ActionReplaceCharacterVisual extends BaseCommand {
13641364
modes = [Mode.Visual, Mode.VisualLine];
13651365
keys = ['r', '<character>'];
1366-
override runsOnceForEveryCursor() {
1367-
return false;
1368-
}
13691366
override createsUndoPoint = true;
13701367

13711368
public override async exec(position: Position, vimState: VimState): Promise<void> {
@@ -1443,9 +1440,6 @@ class ActionReplaceCharacterVisual extends BaseCommand {
14431440
class ActionReplaceCharacterVisualBlock extends BaseCommand {
14441441
modes = [Mode.VisualBlock];
14451442
keys = ['r', '<character>'];
1446-
override runsOnceForEveryCursor() {
1447-
return false;
1448-
}
14491443
override createsUndoPoint = true;
14501444

14511445
public override async exec(position: Position, vimState: VimState): Promise<void> {

test/multicursor.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,29 @@ suite('Multicursor', () => {
6969
});
7070
});
7171

72+
suite('Replace', () => {
73+
newTest({
74+
title: 'r (Normal mode)',
75+
start: ['|cat', 'c|at', 'ca|t'],
76+
keysPressed: 'rX',
77+
end: ['|Xat', 'c|Xt', 'ca|X'],
78+
});
79+
80+
newTest({
81+
title: 'r (Visual mode)',
82+
start: ['|cat', 'c|at', 'ca|t'],
83+
keysPressed: 've' + 'rX',
84+
end: ['|XXX', 'c|XX', 'ca|X'],
85+
});
86+
87+
newTest({
88+
title: 'r (VisualBlock mode)',
89+
start: ['|ca|t', 'cat', 'cat'],
90+
keysPressed: '<C-v>jj' + 'rX',
91+
end: ['|Xa|X', 'XaX', 'XaX'],
92+
});
93+
});
94+
7295
test('can add multiple cursors below', async () => {
7396
await modeHandler.handleMultipleKeyEvents('i11\n22'.split(''));
7497
await modeHandler.handleMultipleKeyEvents(['<Esc>', 'g', 'g']);

0 commit comments

Comments
 (0)