Skip to content

Commit b4c3a3b

Browse files
committed
Support multiple cursors in tests. Fixes #4582.
1 parent 4e9b801 commit b4c3a3b

File tree

9 files changed

+134
-116
lines changed

9 files changed

+134
-116
lines changed

test/mode/modeInsert.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ suite('Mode Insert', () => {
611611
start: ['foo |bar', 'foo bar'],
612612
// create two cursors on bar, yank. Then paste it in insert mode
613613
keysPressed: 'gbgby' + 'i<C-r>"',
614-
end: ['foo bar|bar', 'foo barbar'],
614+
end: ['foo bar|bar', 'foo bar|bar'],
615615
endMode: Mode.Insert,
616616
});
617617

test/mode/modeVisual.test.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,7 +1171,7 @@ suite('Mode Visual', () => {
11711171
title: 'normal selection',
11721172
start: ['this is', 'the| best', 'test i have seen in', 'the world'],
11731173
keysPressed: 'vj$C',
1174-
end: ['this is', '|', 'the world'],
1174+
end: ['this is', '', '|the world'],
11751175
});
11761176
});
11771177

@@ -1187,7 +1187,7 @@ suite('Mode Visual', () => {
11871187
title: 'normal selection',
11881188
start: ['this is', 'the| best', 'test i have seen in', 'the world'],
11891189
keysPressed: 'vj$R',
1190-
end: ['this is', '|', 'the world'],
1190+
end: ['this is', '', '|the world'],
11911191
});
11921192
});
11931193

@@ -1534,21 +1534,21 @@ suite('Mode Visual', () => {
15341534
title: 'multiline insert from bottom up selection',
15351535
start: ['111', '222', '333', '4|44', '555'],
15361536
keysPressed: 'vkkI_',
1537-
end: ['111', '2_|22', '_333', '_444', '555'],
1537+
end: ['111', '2_|22', '_|333', '_|444', '555'],
15381538
});
15391539

15401540
newTest({
15411541
title: 'multiline insert from top down selection',
15421542
start: ['111', '2|22', '333', '444', '555'],
15431543
keysPressed: 'vjjI_',
1544-
end: ['111', '2_|22', '_333', '_444', '555'],
1544+
end: ['111', '2_|22', '_|333', '_|444', '555'],
15451545
});
15461546

15471547
newTest({
15481548
title: 'skips blank lines',
15491549
start: ['111', '2|22', ' ', '444', '555'],
15501550
keysPressed: 'vjjI_',
1551-
end: ['111', '2_|22', ' ', '_444', '555'],
1551+
end: ['111', '2_|22', ' ', '_|444', '555'],
15521552
});
15531553
});
15541554

@@ -1557,21 +1557,21 @@ suite('Mode Visual', () => {
15571557
title: 'multiline append from bottom up selection',
15581558
start: ['111', '222', '333', '4|44', '555'],
15591559
keysPressed: 'vkkA_',
1560-
end: ['111', '222_|', '333_', '44_4', '555'],
1560+
end: ['111', '222_|', '333_|', '44_|4', '555'],
15611561
});
15621562

15631563
newTest({
15641564
title: 'multiline append from top down selection',
15651565
start: ['111', '2|22', '333', '444', '555'],
15661566
keysPressed: 'vjjA_',
1567-
end: ['111', '222_|', '333_', '44_4', '555'],
1567+
end: ['111', '222_|', '333_|', '44_|4', '555'],
15681568
});
15691569

15701570
newTest({
15711571
title: 'skips blank lines',
15721572
start: ['111', '2|22', ' ', '444', '555'],
15731573
keysPressed: 'vjjA_',
1574-
end: ['111', '222_|', ' ', '44_4', '555'],
1574+
end: ['111', '222_|', ' ', '44_|4', '555'],
15751575
});
15761576
});
15771577

@@ -1762,7 +1762,7 @@ suite('Mode Visual', () => {
17621762
end: [
17631763
`"vim.normalModeKeyBindingsNonRecursive": [`,
17641764
` {`,
1765-
` "|before": ["j"],`,
1765+
` "before|": ["j"],`,
17661766
` "after": ["g", "j"],`,
17671767
` },`,
17681768
`]`,

test/mode/modeVisualBlock.test.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,21 @@ suite('VisualBlock mode', () => {
4444
title: '`A` with forward selection',
4545
start: ['t|est', 'test'],
4646
keysPressed: '<C-v>' + 'lj' + 'A123',
47-
end: ['tes123|t', 'tes123t'],
47+
end: ['tes123|t', 'tes123|t'],
4848
});
4949

5050
newTest({
5151
title: '`A` with backward selection',
5252
start: ['te|st', 'test'],
5353
keysPressed: '<C-v>' + 'hj' + 'A123',
54-
end: ['tes123|t', 'tes123t'],
54+
end: ['tes123|t', 'tes123|t'],
5555
});
5656

5757
newTest({
5858
title: '`A` over shorter line adds necessary spaces',
5959
start: ['te|st', 'te', 't'],
6060
keysPressed: '<C-v>' + 'jj' + 'A123',
61-
end: ['tes123|t', 'te 123', 't 123'],
61+
end: ['tes123|t', 'te 123|', 't 123|'],
6262
});
6363
});
6464

@@ -67,29 +67,29 @@ suite('VisualBlock mode', () => {
6767
title: '`I` with forward selection',
6868
start: ['t|est', 'test'],
6969
keysPressed: '<C-v>' + 'lj' + 'I123',
70-
end: ['t123|est', 't123est'],
70+
end: ['t123|est', 't123|est'],
7171
});
7272

7373
newTest({
7474
title: '`I` with backward selection',
7575
start: ['te|st', 'test'],
7676
keysPressed: '<C-v>' + 'hj' + 'I123',
77-
end: ['t123|est', 't123est'],
77+
end: ['t123|est', 't123|est'],
7878
});
7979

8080
newTest({
8181
title: 'Can handle `I` with empty lines on first character (inserts on empty line)',
8282
start: ['|test', '', 'test'],
8383
keysPressed: '<C-v>' + 'lljj' + 'I123',
84-
end: ['123|test', '123', '123test'],
84+
end: ['123|test', '123|', '123|test'],
8585
});
8686

8787
newTest({
8888
title:
8989
'Can handle `I` with empty lines on non-first character (does not insert on empty line)',
9090
start: ['t|est', '', 'test'],
9191
keysPressed: '<C-v>' + 'lljj' + 'I123',
92-
end: ['t123|est', '', 't123est'],
92+
end: ['t123|est', '', 't123|est'],
9393
});
9494
});
9595

@@ -99,21 +99,21 @@ suite('VisualBlock mode', () => {
9999
title: 'With forward selection',
100100
start: ['t|est', 'test'],
101101
keysPressed: '<C-v>' + 'lj' + 'c123',
102-
end: ['t123|t', 't123t'],
102+
end: ['t123|t', 't123|t'],
103103
});
104104

105105
newTest({
106106
title: 'With backward selection',
107107
start: ['te|st', 'test'],
108108
keysPressed: '<C-v>' + 'hj' + 'c123',
109-
end: ['t123|t', 't123t'],
109+
end: ['t123|t', 't123|t'],
110110
});
111111

112112
newTest({
113113
title: 'Skips short lines',
114114
start: ['te|st', '', 'x', 'test'],
115115
keysPressed: '<C-v>' + 'h3j' + 'c123',
116-
end: ['t123|t', '', 'x', 't123t'],
116+
end: ['t123|t', '', 'x', 't123|t'],
117117
});
118118
});
119119
}
@@ -138,15 +138,15 @@ suite('VisualBlock mode', () => {
138138
title: '`C` deletes from block to end of each line, enters multi-cursor Insert mode',
139139
start: ['t|est', 'test'],
140140
keysPressed: '<C-v>jC' + 'xyz',
141-
end: ['txyz|', 'txyz'],
141+
end: ['txyz|', 'txyz|'],
142142
endMode: Mode.Insert,
143143
});
144144

145145
newTest({
146146
title: "Can handle 'gj'",
147147
start: ['t|est', 'test'],
148148
keysPressed: '<C-v>gjI123',
149-
end: ['t123|est', 't123est'],
149+
end: ['t123|est', 't123|est'],
150150
});
151151

152152
suite('`>` (indent at left edge of block)', () => {
@@ -256,14 +256,14 @@ suite('VisualBlock mode', () => {
256256
title: 'Properly add to end of line (`j` then `$`)',
257257
start: ['|Dog', 'Angry', 'Dog', 'Angry', 'Dog'],
258258
keysPressed: '<C-v>4j$Aaa',
259-
end: ['Dogaa|', 'Angryaa', 'Dogaa', 'Angryaa', 'Dogaa'],
259+
end: ['Dogaa|', 'Angryaa|', 'Dogaa|', 'Angryaa|', 'Dogaa|'],
260260
});
261261

262262
newTest({
263263
title: 'Properly add to end of lines (`$` then `j`)',
264264
start: ['|Dog', 'Angry', 'Dog', 'Angry', 'Dog'],
265-
keysPressed: '<C-v>' + '$' + '4j' + 'Aaa<Esc>',
266-
end: ['Doga|a', 'Angryaa', 'Dogaa', 'Angryaa', 'Dogaa'],
265+
keysPressed: '<C-v>' + '$' + '4j' + 'Aaa',
266+
end: ['Dogaa|', 'Angryaa|', 'Dogaa|', 'Angryaa|', 'Dogaa|'],
267267
});
268268

269269
newTest({
@@ -280,7 +280,7 @@ suite('VisualBlock mode', () => {
280280
title: `'${cmd}' deletes block`,
281281
start: ['11111', '2|2222', '33333', '44444', '55555'],
282282
keysPressed: `<C-v>jjll${cmd}`,
283-
end: ['11111', '2|2', '33', '44', '55555'],
283+
end: ['11111', '2|2', cmd === 's' ? '3|3' : '33', cmd === 's' ? '4|4' : '44', '55555'],
284284
endMode: cmd === 's' ? Mode.Insert : Mode.Normal,
285285
});
286286
}
@@ -352,23 +352,23 @@ suite('VisualBlock mode', () => {
352352
title: "Can handle 'gJ' when the visual block spans multiple lines",
353353
start: ['o|ne', 'two', 'three', 'four'],
354354
keysPressed: '<C-v>jjlgJ',
355-
end: ['onetwo|three', 'four'],
355+
end: ['onetwo|t|hre|e', 'four'], // TODO(#9830): Should have only one cursor
356356
endMode: Mode.Normal,
357357
});
358358

359359
newTest({
360360
title: "Can handle 'gJ' when the visual block spans multiple lines and line has whitespaces",
361361
start: ['o|ne ', 'two', ' three', 'four'],
362362
keysPressed: '<C-v>jjlgJ',
363-
end: ['one two| three', 'four'],
363+
end: ['one two| | thre|e', 'four'], // TODO(#9830): Should have only one cursor
364364
endMode: Mode.Normal,
365365
});
366366

367367
newTest({
368368
title: "Can handle 'gJ' when start position of the visual block is below the stop",
369369
start: ['one', 'two', 't|hree', 'four'],
370370
keysPressed: '<C-v>kkgJ',
371-
end: ['onetwo|three', 'four'],
371+
end: ['onetwo|thre|e', 'four'], // TODO(#9830): Should have only one cursor
372372
endMode: Mode.Normal,
373373
});
374374
});

test/mode/modeVisualLine.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -446,21 +446,21 @@ suite('Mode Visual Line', () => {
446446
title: 'multiline insert from bottom up selection',
447447
start: ['111', '222', '333', '4|44', '555'],
448448
keysPressed: 'VkkI_',
449-
end: ['111', '_|222', '_333', '_444', '555'],
449+
end: ['111', '_|222', '_|333', '_|444', '555'],
450450
});
451451

452452
newTest({
453453
title: 'multiline insert from top down selection',
454454
start: ['111', '2|22', '333', '444', '555'],
455455
keysPressed: 'VjjI_',
456-
end: ['111', '_|222', '_333', '_444', '555'],
456+
end: ['111', '_|222', '_|333', '_|444', '555'],
457457
});
458458

459459
newTest({
460460
title: 'skips blank lines',
461461
start: ['111', '2|22', ' ', '444', '555'],
462462
keysPressed: 'VjjI_',
463-
end: ['111', '_|222', ' ', '_444', '555'],
463+
end: ['111', '_|222', ' ', '_|444', '555'],
464464
});
465465
});
466466

@@ -469,21 +469,21 @@ suite('Mode Visual Line', () => {
469469
title: 'multiline append from bottom up selection',
470470
start: ['111', '222', '333', '4|44', '555'],
471471
keysPressed: 'VkkA_',
472-
end: ['111', '222_|', '333_', '444_', '555'],
472+
end: ['111', '222_|', '333_|', '444_|', '555'],
473473
});
474474

475475
newTest({
476476
title: 'multiline append from top down selection',
477477
start: ['111', '2|22', '333', '444', '555'],
478478
keysPressed: 'VjjA_',
479-
end: ['111', '222_|', '333_', '444_', '555'],
479+
end: ['111', '222_|', '333_|', '444_|', '555'],
480480
});
481481

482482
newTest({
483483
title: 'skips blank lines',
484484
start: ['111', '2|22', ' ', '444', '555'],
485485
keysPressed: 'VjjA_',
486-
end: ['111', '222_|', ' ', '444_', '555'],
486+
end: ['111', '222_|', ' ', '444_|', '555'],
487487
});
488488

489489
newTest({

test/number/incrementDecrement.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,15 @@ suite('Increment/decrement (<C-a> and <C-x>)', () => {
239239
title: '<C-a> in visual block mode',
240240
start: ['9 9 9', '9 |9 9', '9 9 9', '9 9 9', '9 9 9'],
241241
keysPressed: '<C-v>jj3<C-a>',
242-
end: ['9 9 9', '9 |12 9', '9 12 9', '9 12 9', '9 9 9'],
242+
end: ['9 9 9', '9 |12 9', '9 1|2 9', '9 1|2 9', '9 9 9'], // TODO: Bad cursor position?
243243
endMode: Mode.Normal,
244244
});
245245

246246
newTest({
247247
title: '<C-a> in visual block mode does not go past selection',
248248
start: ['9 9 9', '9| 9 9', '9 9 9', '9 9 9', '9 9 9'],
249249
keysPressed: '<C-v>jj3<C-a>',
250-
end: ['9 9 9', '9| 9 9', '9 9 9', '9 9 9', '9 9 9'],
250+
end: ['9 9 9', '9| 9 9', '9| 9 9', '9| 9 9', '9 9 9'],
251251
endMode: Mode.Normal,
252252
});
253253

@@ -271,7 +271,7 @@ suite('Increment/decrement (<C-a> and <C-x>)', () => {
271271
title: 'g<C-a> in visual block mode',
272272
start: ['9 9 9', '9 |9 9', '9 9 9', '9 9 9', '9 9 9'],
273273
keysPressed: '<C-v>jj3g<C-a>',
274-
end: ['9 9 9', '9 |12 9', '9 15 9', '9 18 9', '9 9 9'],
274+
end: ['9 9 9', '9 |12 9', '9 1|5 9', '9 1|8 9', '9 9 9'], // TODO: Bad cursor position?
275275
endMode: Mode.Normal,
276276
});
277277
});

0 commit comments

Comments
 (0)