trptcolin/reply — Issue #13: Control-D kills the REPL prematurely
Author: cosmin
Created: 2012-01-20 05:52:51+00:00
State: open

Ctrl-D is a very useful readline bindings for forward delete. It's also used as a convention to kill the REPL if typed by itself at the beginning of a line.

In your current implementation however, attempting to use Ctrl-D as forward-delete at any point in the line will immediately kill the REPL, which is unexpected.

I recommend checking the current cursor or buffer size to determine if there are actual characters to delete and keeping the current forward delete behavior unless the buffer is empty. You should be able to determine if it's safe to kill the REPL with something along the lines of:

reader.getCursorBuffer().cursor == 0 && reader.getCursorBuffer().length() == 0

and invoking

reader.delete() otherwise to keep the expected Ctrl-D behavior.