vi-mode: Add 'dG' to delete to the end of multiline buffer (#1692)

This commit is contained in:
Maxime Labelle
2020-07-25 11:06:54 -07:00
committed by GitHub
parent c266e55b59
commit c7ef3bd0f6
5 changed files with 43 additions and 0 deletions
+1
View File
@@ -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):
+1
View File
@@ -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") },
+3
View File
@@ -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>
+18
View File
@@ -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>
+20
View File
@@ -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()
{