aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-04-08 19:01:08 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-04-08 19:02:37 +0800
commit38506553f7213cc9df0f222c29127a9f182351e4 (patch)
tree3c9c776529289b693610ed988e9ea57560cdd17d
parent2c7dc648ca796786b4847771c1df71dea20a1774 (diff)
downloadrneovim-38506553f7213cc9df0f222c29127a9f182351e4.tar.gz
rneovim-38506553f7213cc9df0f222c29127a9f182351e4.tar.bz2
rneovim-38506553f7213cc9df0f222c29127a9f182351e4.zip
vim-patch:8.2.4711: when 'insermode' is set :edit from <Cmd> mapping misbehaves
Problem: When 'insermode' is set :edit from <Cmd> mapping misbehaves. Solution: Don't set "need_start_insertmode" when already in Insert mode. (closes vim/vim#10116) https://github.com/vim/vim/commit/3a56b6d405fc0f1ca928b77382f97d0c552bea64
-rw-r--r--src/nvim/ex_cmds.c2
-rw-r--r--src/nvim/testdir/test_edit.vim23
2 files changed, 24 insertions, 1 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 4e98319723..98aabe89b3 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -2875,7 +2875,7 @@ int do_ecmd(int fnum, char_u *ffname, char_u *sfname, exarg_T *eap, linenr_T new
redraw_curbuf_later(NOT_VALID); // redraw this buffer later
}
- if (p_im) {
+ if (p_im && (State & INSERT) == 0) {
need_start_insertmode = true;
}
diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim
index 360b3aaaa0..eea5d190b2 100644
--- a/src/nvim/testdir/test_edit.vim
+++ b/src/nvim/testdir/test_edit.vim
@@ -1627,6 +1627,29 @@ func Test_edit_is_a_directory()
call delete(dirname, 'rf')
endfunc
+" Using :edit without leaving 'insertmode' should not cause Insert mode to be
+" re-entered immediately after <C-L>
+func Test_edit_insertmode_ex_edit()
+ CheckRunVimInTerminal
+
+ let lines =<< trim END
+ set insertmode noruler
+ inoremap <C-B> <Cmd>edit Xfoo<CR>
+ END
+ call writefile(lines, 'Xtest_edit_insertmode_ex_edit')
+
+ let buf = RunVimInTerminal('-S Xtest_edit_insertmode_ex_edit', #{rows: 6})
+ call TermWait(buf, 50)
+ call assert_match('^-- INSERT --\s*$', term_getline(buf, 6))
+ call term_sendkeys(buf, "\<C-B>\<C-L>")
+ call TermWait(buf, 50)
+ call assert_notmatch('^-- INSERT --\s*$', term_getline(buf, 6))
+
+ " clean up
+ call StopVimInTerminal(buf)
+ call delete('Xtest_edit_insertmode_ex_edit')
+endfunc
+
func Test_edit_browse()
" in the GUI this opens a file picker, we only test the terminal behavior
CheckNotGui