mirror of
https://github.com/PowerShell/PSReadLine
synced 2026-06-08 12:12:13 +00:00
vi-mode: Add 'dG' to delete to the end of multiline buffer (#1692)
This commit is contained in:
@@ -398,6 +398,7 @@ namespace Microsoft.PowerShell
|
||||
case nameof(Cut):
|
||||
case nameof(DeleteChar):
|
||||
case nameof(DeleteCharOrExit):
|
||||
case nameof(DeleteEndOfBuffer):
|
||||
case nameof(DeleteEndOfWord):
|
||||
case nameof(DeleteLine):
|
||||
case nameof(DeleteLineToFirstChar):
|
||||
|
||||
@@ -226,6 +226,7 @@ namespace Microsoft.PowerShell
|
||||
{ Keys.W, MakeKeyHandler( DeleteWord, "DeleteWord") },
|
||||
{ Keys.ucW, MakeKeyHandler( ViDeleteGlob, "ViDeleteGlob") },
|
||||
{ Keys.E, MakeKeyHandler( DeleteEndOfWord, "DeleteEndOfWord") },
|
||||
{ Keys.ucG, MakeKeyHandler( DeleteEndOfBuffer, "DeleteEndOfBuffer") },
|
||||
{ Keys.ucE, MakeKeyHandler( ViDeleteEndOfGlob, "ViDeleteEndOfGlob") },
|
||||
{ Keys.H, MakeKeyHandler( BackwardDeleteChar, "BackwardDeleteChar") },
|
||||
{ Keys.L, MakeKeyHandler( DeleteChar, "DeleteChar") },
|
||||
|
||||
@@ -802,4 +802,7 @@ Or not saving history with:
|
||||
<data name="PredictiveSuggestionNotSupported" xml:space="preserve">
|
||||
<value>The predictive suggestion feature cannot be enabled because the console output doesn't support virtual terminal processing or it's redirected.</value>
|
||||
</data>
|
||||
<data name="DeleteEndOfBufferDescription" xml:space="preserve">
|
||||
<value>Delete the current logical line and up to the end of the multiline buffer</value>
|
||||
</data>
|
||||
</root>
|
||||
|
||||
@@ -782,6 +782,24 @@ namespace Microsoft.PowerShell
|
||||
return deletePosition;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes from the current logical line to the end of the buffer.
|
||||
/// </summary>
|
||||
public static void DeleteEndOfBuffer(ConsoleKeyInfo? key = null, object arg = null)
|
||||
{
|
||||
var lineIndex = _singleton.GetLogicalLineNumber() - 1;
|
||||
var lineCount = _singleton.GetLogicalLineCount() - lineIndex;
|
||||
|
||||
DeleteLineImpl(lineIndex, lineCount);
|
||||
|
||||
// move the cursor to the beginning of the previous line
|
||||
var previousLineIndex = Math.Max(0, lineIndex - 1);
|
||||
var newPosition = GetBeginningOfNthLinePos(previousLineIndex);
|
||||
|
||||
_singleton._current = newPosition;
|
||||
_singleton.Render();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the previous word.
|
||||
/// </summary>
|
||||
|
||||
@@ -469,6 +469,26 @@ namespace Test
|
||||
));
|
||||
}
|
||||
|
||||
[SkippableFact]
|
||||
public void ViDeleteToEndOfBuffer()
|
||||
{
|
||||
TestSetup(KeyMode.Vi);
|
||||
|
||||
Test("\"-\"", Keys(
|
||||
_.DQuote, "-", _.Enter,
|
||||
"one", _.Enter,
|
||||
"two", _.Enter,
|
||||
"three", _.Enter,
|
||||
_.DQuote, _.Escape,
|
||||
"kkkl", // go to the 'ne' portion of "one"
|
||||
// delete to the end of the next line
|
||||
"dG",
|
||||
CheckThat(() => AssertCursorLeftIs(0)),
|
||||
// terminate the buffer
|
||||
_.A, _.DQuote
|
||||
));
|
||||
}
|
||||
|
||||
[SkippableFact]
|
||||
public void ViGlobDelete()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user