From f5fac096c0abcf5ee1e62bb932712aa9dc493e21 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Wed, 19 Apr 2017 22:59:53 +0200 Subject: [PATCH] Don't move cursor in delete-char Instead, move forward and backward in vi-mode. Fixes #3899. --- share/functions/fish_vi_key_bindings.fish | 9 ++++++--- src/reader.cpp | 3 --- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/share/functions/fish_vi_key_bindings.fish b/share/functions/fish_vi_key_bindings.fish index 05ed9dedc..b41c7e4b6 100644 --- a/share/functions/fish_vi_key_bindings.fish +++ b/share/functions/fish_vi_key_bindings.fish @@ -118,10 +118,13 @@ function fish_vi_key_bindings --description 'vi-like key bindings for fish' bind -M insert -k end end-of-line 2>/dev/null bind -M default -k end end-of-line 2>/dev/null - bind -M default x delete-char + # Vi moves the cursor back if, after deleting, it is at EOL. + # To emulate that, move forward, then backward, which will be a NOP + # if there is something to move forward to. + bind -M default x delete-char forward-char backward-char bind -M default X backward-delete-char - bind -M insert -k dc delete-char - bind -M default -k dc delete-char + bind -M insert -k dc delete-char forward-char backward-char + bind -M default -k dc delete-char forward-char backward-char # Backspace deletes a char in insert mode, but not in normal/default mode. bind -M insert -k backspace backward-delete-char diff --git a/src/reader.cpp b/src/reader.cpp index 5447a3335..9e47aef25 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -2709,9 +2709,6 @@ const wchar_t *reader_readline(int nchars) { if (el->position < el->size()) { update_buff_pos(el, el->position + 1); remove_backward(); - if (el->position > 0 && el->position == el->size()) { - update_buff_pos(el, el->position - 1); - } } break; }