Skip to content

Commit fc33a12

Browse files
committed
Resolve ViGotoBrace Reviews
1 parent 0c3f945 commit fc33a12

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

PSReadLine/Movement.vi.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,10 @@ private int ViFindBrace(int i)
261261
for (int idx = 0; idx < parenthese.Length; idx++)
262262
if (parenthese[idx] == _buffer[nextParen]) goto Outer;
263263

264+
// if not found, nextParen could exceed the range
265+
if (nextParen >= _buffer.Length)
266+
return i;
267+
264268
Outer:
265269
int match = _buffer[nextParen] switch
266270
{

test/MovementTest.VI.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System.Collections.Generic;
2-
using Xunit;
1+
using Xunit;
32

43
namespace Test
54
{
@@ -477,7 +476,7 @@ public void ViGotoBrace()
477476

478477
// Closing paren without backward match
479478
string input2 = $"0]2)4foo{closing}";
480-
Test(input2, Keys(
479+
TestMustDing(input2, Keys(
481480
input2,
482481
CheckThat(() => AssertCursorLeftIs(9)),
483482
_.Escape, CheckThat(() => AssertCursorLeftIs(8)),

0 commit comments

Comments
 (0)