Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 19 additions & 14 deletions PSReadLine/Movement.vi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,14 @@ public static void ViEndOfPreviousGlob(ConsoleKeyInfo? key = null, object arg =
/// Move the cursor to the end of the current logical line.
/// </summary>
public static void MoveToEndOfLine(ConsoleKeyInfo? key = null, object arg = null)
{
var eol = GetEndOfLogicalLinePos(_singleton._current);
if (eol != _singleton._current)
{
_singleton.MoveCursor(eol);
}
_singleton._moveToEndOfLineCommandCount++;
_singleton._moveToLineDesiredColumn = int.MaxValue;
{
var eol = GetEndOfLogicalLinePos(_singleton._current);
if (eol != _singleton._current)
{
_singleton.MoveCursor(eol);
}
_singleton._moveToEndOfLineCommandCount++;
_singleton._moveToLineDesiredColumn = int.MaxValue;
}

/// <summary>
Expand All @@ -189,7 +189,7 @@ public static void NextWordEnd(ConsoleKeyInfo? key = null, object arg = null)
public static void GotoColumn(ConsoleKeyInfo? key = null, object arg = null)
{
int col = arg as int? ?? -1;
if (col < 0)
if (col < 0)
{
Ding();
return;
Expand All @@ -210,11 +210,11 @@ public static void GotoColumn(ConsoleKeyInfo? key = null, object arg = null)
/// Move the cursor to the first non-blank character in the line.
/// </summary>
public static void GotoFirstNonBlankOfLine(ConsoleKeyInfo? key = null, object arg = null)
{
var newCurrent = GetFirstNonBlankOfLogicalLinePos(_singleton._current);
if (newCurrent != _singleton._current)
{
_singleton.MoveCursor(newCurrent);
{
var newCurrent = GetFirstNonBlankOfLogicalLinePos(_singleton._current);
if (newCurrent != _singleton._current)
{
_singleton.MoveCursor(newCurrent);
}
}

Expand All @@ -234,6 +234,11 @@ public static void ViGotoBrace(ConsoleKeyInfo? key = null, object arg = null)

private int ViFindBrace(int i)
{
if (_buffer.Length == 0)
{
return i;
}

switch (_buffer[i])
{
case '{':
Expand Down
5 changes: 5 additions & 0 deletions test/MovementTest.VI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,11 @@ public void ViGotoBrace()
"ddi"
));
}

// <%> with empty text buffer should work fine.
Test("", Keys(
_.Escape, _.Percent,
CheckThat(() => AssertCursorLeftIs(0))));
}

[SkippableFact]
Expand Down