Skip to content

Commit 352edb9

Browse files
authored
Use 'd^' to delete from the first non-blank character of a logical line (#2001)
1 parent a7fd34f commit 352edb9

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

PSReadLine/PSReadLineResources.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ If there are other parse errors, unresolved commands, or incorrect parameters, s
476476
<value>Switches to insert mode after positioning the cursor past the end of the line.</value>
477477
</data>
478478
<data name="DeleteLineToFirstCharDescription" xml:space="preserve">
479-
<value>Deletes all of the line except for leading whitespace.</value>
479+
<value>Deletes from the first non blank character of the current logical line in a multiline buffer.</value>
480480
</data>
481481
<data name="BackwardReplaceCharDescription" xml:space="preserve">
482482
<value>Replaces the character in front of the cursor.</value>

PSReadLine/ReadLine.vi.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -722,14 +722,7 @@ public static void DeleteLineToFirstChar(ConsoleKeyInfo? key = null, object arg
722722
{
723723
if (_singleton._current > 0)
724724
{
725-
int i = 0;
726-
for (; i < _singleton._current; i++)
727-
{
728-
if (!Char.IsWhiteSpace(_singleton._buffer[i]))
729-
{
730-
break;
731-
}
732-
}
725+
var i = GetFirstNonBlankOfLogicalLinePos(_singleton._current);
733726

734727
_singleton.SaveToClipboard(i, _singleton._current - i);
735728
_singleton.SaveEditItem(EditItemDelete.Create(_clipboard, i, DeleteLineToFirstChar));

test/BasicEditingTest.VI.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,25 @@ public void ViDeleteToEnd()
549549
));
550550
}
551551

552+
[SkippableFact]
553+
public void ViDeleteLineToFirstChar()
554+
{
555+
TestSetup(KeyMode.Vi);
556+
557+
int continuationPrefixLength = PSConsoleReadLineOptions.DefaultContinuationPrompt.Length;
558+
559+
Test("\"\n some spaces\n\"", Keys(
560+
_.DQuote, _.Enter,
561+
" this is a line with some spaces", _.Enter,
562+
_.DQuote, _.Escape,
563+
"k6W",
564+
CheckThat(() => AssertCursorLeftIs(continuationPrefixLength + 23)),
565+
// delete from first non blank of line
566+
"d^",
567+
CheckThat(() => AssertCursorLeftIs(continuationPrefixLength + 3))
568+
));
569+
}
570+
552571
[SkippableFact]
553572
public void ViDeleteNextLines()
554573
{

0 commit comments

Comments
 (0)