Skip to content

Commit 803008a

Browse files
springcomplzybkr
authored andcommitted
ViAppendLine crashes with cursor at end of input on empty line (#797)
Fix #796
1 parent 2101854 commit 803008a

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

PSReadLine/ReadLine.vi.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,6 +1189,10 @@ private bool IsAtEndOfPhrase()
11891189
{
11901190
return true;
11911191
}
1192+
if (_current == _buffer.Length && _buffer[_current - 1] == '\n')
1193+
{
1194+
return true;
1195+
}
11921196
if (_buffer[_current] == '\n')
11931197
{
11941198
return true;

test/BasicEditingTest.VI.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,19 @@ public void ViDefect628()
120120
));
121121
}
122122

123+
[Fact]
124+
public void Defect796()
125+
{
126+
TestSetup(KeyMode.Vi);
127+
128+
Test("\"\n\n\"", Keys(
129+
_.DQuote, _.Enter, _.Escape, CheckThat(() => AssertCursorTopIs(0)),
130+
'j', CheckThat(() => AssertCursorTopIs(1)),
131+
'o', CheckThat(() => AssertCursorTopIs(2)),
132+
_.DQuote
133+
));
134+
}
135+
123136
[Fact]
124137
public void ViChangeMovementUndo()
125138
{

0 commit comments

Comments
 (0)