|
1 | | -using Xunit; |
| 1 | +using System.Collections.Generic; |
| 2 | +using Xunit; |
2 | 3 |
|
3 | 4 | namespace Test |
4 | 5 | { |
@@ -370,7 +371,7 @@ public void ViGlobMovement_EmptyBuffer_Defect1195() |
370 | 371 | TestSetup(KeyMode.Vi); |
371 | 372 |
|
372 | 373 | TestMustDing("", Keys( |
373 | | - _.Escape, "W" |
| 374 | + _.Escape, "W" |
374 | 375 | )); |
375 | 376 | } |
376 | 377 |
|
@@ -454,6 +455,53 @@ public void ViGotoBrace() |
454 | 455 | )); |
455 | 456 | } |
456 | 457 |
|
| 458 | + // tests when cursor not on any paren |
| 459 | + foreach (var (opening, closing) in new[] { ('(', ')'), ('{', '}'), ('[', ']') }) |
| 460 | + { |
| 461 | + // closing paren with backward match |
| 462 | + string input1 = $"0{opening}2{opening}4foo{closing}"; |
| 463 | + Test(input1, Keys( |
| 464 | + input1, |
| 465 | + CheckThat(() => AssertCursorLeftIs(9)), |
| 466 | + _.Escape, CheckThat(() => AssertCursorLeftIs(8)), |
| 467 | + "0ff", CheckThat(() => AssertCursorLeftIs(5)), |
| 468 | + _.Percent, CheckThat(() => AssertCursorLeftIs(3)), |
| 469 | + _.Percent, CheckThat(() => AssertCursorLeftIs(8)) |
| 470 | + )); |
| 471 | + |
| 472 | + // closing paren without backward match |
| 473 | + string input2 = $"0]2)4foo{closing}"; |
| 474 | + Test(input2, Keys( |
| 475 | + input2, |
| 476 | + CheckThat(() => AssertCursorLeftIs(9)), |
| 477 | + _.Escape, CheckThat(() => AssertCursorLeftIs(8)), |
| 478 | + "0ff", CheckThat(() => AssertCursorLeftIs(5)), |
| 479 | + _.Percent, CheckThat(() => AssertCursorLeftIs(5)), // stay still |
| 480 | + _.Percent, CheckThat(() => AssertCursorLeftIs(5)) |
| 481 | + )); |
| 482 | + |
| 483 | + // opening paren with forward match |
| 484 | + string input3 = $"0{opening}2foo6{closing}"; |
| 485 | + Test(input3, Keys( |
| 486 | + input3, |
| 487 | + CheckThat(() => AssertCursorLeftIs(8)), |
| 488 | + _.Escape, CheckThat(() => AssertCursorLeftIs(7)), |
| 489 | + "0ff", CheckThat(() => AssertCursorLeftIs(3)), |
| 490 | + _.Percent, CheckThat(() => AssertCursorLeftIs(1)), |
| 491 | + _.Percent, CheckThat(() => AssertCursorLeftIs(7)) |
| 492 | + )); |
| 493 | + // opening paren without forward match |
| 494 | + string input4 = $"0)2]4foo{opening}("; |
| 495 | + Test(input4, Keys( |
| 496 | + input4, |
| 497 | + CheckThat(() => AssertCursorLeftIs(10)), |
| 498 | + _.Escape, CheckThat(() => AssertCursorLeftIs(9)), |
| 499 | + "0ff", CheckThat(() => AssertCursorLeftIs(5)), |
| 500 | + _.Percent, CheckThat(() => AssertCursorLeftIs(5)), // stay still |
| 501 | + _.Percent, CheckThat(() => AssertCursorLeftIs(5)) |
| 502 | + )); |
| 503 | + } |
| 504 | + |
457 | 505 | // <%> with empty text buffer should work fine. |
458 | 506 | Test("", Keys( |
459 | 507 | _.Escape, _.Percent, |
|
0 commit comments