dwmkerr / consolecontrol

ConsoleControl is a C# class library that lets you embed a console in a WinForms or WPF application.
MIT License
723 stars 169 forks source link

Backspace deletes last readonly character #54

Open suleyman-shb opened 3 years ago

suleyman-shb commented 3 years ago

Steps to reproduct: Start new "ConsoleControlSample.WPF" process. Click "Run command" starts new command shell Hit backspace on input area Last character on output, probable a ">" character is removed.

Fix proposal: on "richTextBoxConsole_PreviewKeyDown" method, change

var caretPosition = richTextBoxConsole.GetCaretPosition();
var delta = caretPosition - inputStartPos;
var inReadOnlyZone = delta < 0;

with this

var caretPosition = richTextBoxConsole.GetCaretPosition();
var delta = caretPosition - inputStartPos;
var inReadOnlyZone = delta <= 0;