Skip to content

Commit

Permalink
Adds support for C-d delete
Browse files Browse the repository at this point in the history
Fixes #40
  • Loading branch information
rubberduck203 committed May 4, 2018
1 parent e6dda7a commit c85a1e6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ It is cross platform and runs anywhere .NET is supported, targeting `netstandard
| `Ctrl`+`U` | Cut text to the start of line |
| `Ctrl`+`W` | Cut previous word |
| `Backspace` | Delete previous character |
| `Delete` | Delete succeeding character |
| `Ctrl` + `D` / `Delete` | Delete succeeding character |


## Installation
Expand Down
1 change: 1 addition & 0 deletions src/ReadLine/KeyHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ public KeyHandler(IConsole console, List<string> history, IAutoCompleteHandler a
_keyActions["ControlE"] = MoveCursorEnd;
_keyActions["Backspace"] = Backspace;
_keyActions["Delete"] = Delete;
_keyActions["ControlD"] = Delete;
_keyActions["ControlH"] = Backspace;
_keyActions["ControlL"] = ClearLine;
_keyActions["Escape"] = ClearLine;
Expand Down
15 changes: 15 additions & 0 deletions test/ReadLine.Tests/KeyHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,21 @@ public void TestRightArrow()
Assert.Equal("Hello!", _keyHandler.Text);
}

[Fact]
public void TestControlD()
{
for (var i = 0; i < 4; i++)
{
_keyInfo = new ConsoleKeyInfo('\0', ConsoleKey.LeftArrow, false, false, false);
_keyHandler.Handle(_keyInfo);
}

_keyInfo = new ConsoleKeyInfo('\u0004', ConsoleKey.D, false, false, true);
_keyHandler.Handle(_keyInfo);

Assert.Equal("Hllo", _keyHandler.Text);
}

[Fact]
public void TestControlF()
{
Expand Down

0 comments on commit c85a1e6

Please sign in to comment.