aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSean Dewar <seandewar@users.noreply.github.com>2021-11-07 21:14:36 +0000
committerSean Dewar <seandewar@users.noreply.github.com>2021-12-07 11:34:27 +0000
commitc2d0a1041e215634be316c4e824c1b1b2f242e76 (patch)
tree50c7411827bcc76853a7fa354d9c5bb90fd692cd /src
parenta128b64e73322a41b175811dc88a7f7046278de3 (diff)
downloadrneovim-c2d0a1041e215634be316c4e824c1b1b2f242e76.tar.gz
rneovim-c2d0a1041e215634be316c4e824c1b1b2f242e76.tar.bz2
rneovim-c2d0a1041e215634be316c4e824c1b1b2f242e76.zip
vim-patch:8.2.1976: cannot backspace in prompt buffer after using cursor-left
Problem: Cannot backspace in prompt buffer after using cursor-left. (Maxim Kim) Solution: Ignore "arrow_used" in a prompt buffer. (closes vim/vim#7281) https://github.com/vim/vim/commit/6f6244855fbce5aaa718cd5001a29aac3c5c15d6 cmdchar_todo wasn't adapted properly for Nvim's state system, which caused it to be a dead store and such was removed in #11900. Re-introduce cmdchar_todo properly.
Diffstat (limited to 'src')
-rw-r--r--src/nvim/edit.c7
-rw-r--r--src/nvim/testdir/test_prompt_buffer.vim8
2 files changed, 13 insertions, 2 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 6e3efe8bba..dfdefddc20 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -227,6 +227,7 @@ typedef struct insert_state {
cmdarg_T *ca;
int mincol;
int cmdchar;
+ int cmdchar_todo; // cmdchar to handle once in init_prompt
int startln;
long count;
int c;
@@ -290,6 +291,7 @@ static void insert_enter(InsertState *s)
s->did_backspace = true;
s->old_topfill = -1;
s->replaceState = REPLACE;
+ s->cmdchar_todo = s->cmdchar;
// Remember whether editing was restarted after CTRL-O
did_restart_edit = restart_edit;
// sleep before redrawing, needed for "CTRL-O :" that results in an
@@ -585,7 +587,8 @@ static int insert_check(VimState *state)
}
if (bt_prompt(curbuf)) {
- init_prompt(s->cmdchar);
+ init_prompt(s->cmdchar_todo);
+ s->cmdchar_todo = NUL;
}
// If we inserted a character at the last position of the last line in the
@@ -8268,7 +8271,7 @@ static bool ins_bs(int c, int mode, int *inserted_space_p)
|| (!revins_on
&& ((curwin->w_cursor.lnum == 1 && curwin->w_cursor.col == 0)
|| (!can_bs(BS_START)
- && (arrow_used
+ && ((arrow_used && !bt_prompt(curbuf))
|| (curwin->w_cursor.lnum == Insstart_orig.lnum
&& curwin->w_cursor.col <= Insstart_orig.col)))
|| (!can_bs(BS_INDENT) && !arrow_used && ai_col > 0
diff --git a/src/nvim/testdir/test_prompt_buffer.vim b/src/nvim/testdir/test_prompt_buffer.vim
index 72b037dd37..af7231c9c0 100644
--- a/src/nvim/testdir/test_prompt_buffer.vim
+++ b/src/nvim/testdir/test_prompt_buffer.vim
@@ -126,6 +126,14 @@ func Test_prompt_garbage_collect()
bwipe!
endfunc
+func Test_prompt_backspace()
+ new
+ set buftype=prompt
+ call feedkeys("A123456\<Left>\<BS>\<Esc>", 'xt')
+ call assert_equal('% 12346', getline(1))
+ bwipe!
+endfunc
+
" Test for editing the prompt buffer
func Test_prompt_buffer_edit()
new