Skip to content

Commit

Permalink
Fix UpHat (^) in vi-mode to move the cursor while yanking (#1656)
Browse files Browse the repository at this point in the history
  • Loading branch information
springcomp committed Jul 13, 2020
1 parent a88c22f commit 6cacbeb
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 14 deletions.
16 changes: 4 additions & 12 deletions PSReadLine/YankPaste.vi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,20 +265,12 @@ public static void ViYankBeginningOfLine(ConsoleKeyInfo? key = null, object arg
/// </summary>
public static void ViYankToFirstChar(ConsoleKeyInfo? key = null, object arg = null)
{
int start = 0;
while (_singleton.IsWhiteSpace(start))
{
start++;
}
if (start == _singleton._current)
{
return;
}

int length = _singleton._current - start;
var start = GetFirstNonBlankOfLogicalLinePos(_singleton._current);
var length = _singleton._current - start;
if (length > 0)
{
_singleton.SaveToClipboard(start, length);
_clipboard.Record(_singleton._buffer, start, length);
_singleton.MoveCursor(start);
}
}

Expand Down
4 changes: 2 additions & 2 deletions test/YankPasteTest.VI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -379,13 +379,13 @@ public void ViPasteAfterYankFirstNoneBlank()

Test("012", Keys(
"012", _.Escape,
"y", _.Uphat, "P", CheckThat(() => AssertLineIs("01012")), CheckThat(() => AssertCursorLeftIs(3)),
"y", _.Uphat, "P", CheckThat(() => AssertLineIs("01012")), CheckThat(() => AssertCursorLeftIs(1)),
"u"
));

Test(" 123 ", Keys(
" 123 ", _.Escape,
"y", _.Uphat, "P", CheckThat(() => AssertLineIs(" 123 123 ")), CheckThat(() => AssertCursorLeftIs(8)),
"y", _.Uphat, "P", CheckThat(() => AssertLineIs(" 123 123 ")), CheckThat(() => AssertCursorLeftIs(4)),
"u"
));
}
Expand Down

0 comments on commit 6cacbeb

Please sign in to comment.