aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-06-26 15:54:00 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-08-15 17:58:35 +0800
commit55da52963b6e13ecc402b6574cf3bd396d11d23d (patch)
tree1b45b1ba5c3fa4ed66dc74dce66acfa27e761524
parent93ba82183122b6b6e3d388d0e0fad4a538052803 (diff)
downloadrneovim-55da52963b6e13ecc402b6574cf3bd396d11d23d.tar.gz
rneovim-55da52963b6e13ecc402b6574cf3bd396d11d23d.tar.bz2
rneovim-55da52963b6e13ecc402b6574cf3bd396d11d23d.zip
vim-patch:8.2.5109: mode not updated after CTRL-O CTRL-C in Insert mode
Problem: Mode not updated after CTRL-O CTRL-C in Insert mode. Solution: Set redraw_mode and use it. (closes vim/vim#10581) https://github.com/vim/vim/commit/7a1d32809bb5c1527314000983e75125d79192e0
-rw-r--r--src/nvim/normal.c6
-rw-r--r--src/nvim/testdir/test_normal.vim19
-rw-r--r--test/functional/legacy/messages_spec.lua22
3 files changed, 44 insertions, 3 deletions
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index c28ffaa22e..a623c14a8e 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -1284,7 +1284,7 @@ static void normal_redraw(NormalState *s)
update_screen(INVERTED);
} else if (must_redraw) {
update_screen(0);
- } else if (redraw_cmdline || clear_cmdline) {
+ } else if (redraw_cmdline || clear_cmdline || redraw_mode) {
showmode();
}
@@ -6930,6 +6930,10 @@ static void nv_esc(cmdarg_T *cap)
}
}
+ if (restart_edit != 0) {
+ redraw_mode = true; // remove "-- (insert) --"
+ }
+
restart_edit = 0;
if (cmdwin_type != 0) {
diff --git a/src/nvim/testdir/test_normal.vim b/src/nvim/testdir/test_normal.vim
index 7cb70aa2af..523b9b8781 100644
--- a/src/nvim/testdir/test_normal.vim
+++ b/src/nvim/testdir/test_normal.vim
@@ -3,6 +3,7 @@
source shared.vim
source check.vim
source view_util.vim
+source screendump.vim
func Setup_NewWindow()
10new
@@ -2038,9 +2039,9 @@ func Test_normal33_g_cmd2()
call assert_equal(2, line('.'))
call assert_fails(':norm! g;', 'E662')
call assert_fails(':norm! g,', 'E663')
- let &ul=&ul
+ let &ul = &ul
call append('$', ['a', 'b', 'c', 'd'])
- let &ul=&ul
+ let &ul = &ul
call append('$', ['Z', 'Y', 'X', 'W'])
let a = execute(':changes')
call assert_match('2\s\+0\s\+2', a)
@@ -2889,6 +2890,20 @@ func Test_message_when_using_ctrl_c()
bwipe!
endfunc
+func Test_mode_updated_after_ctrl_c()
+ CheckScreendump
+
+ let buf = RunVimInTerminal('', {'rows': 5})
+ call term_sendkeys(buf, "i")
+ call term_sendkeys(buf, "\<C-O>")
+ " wait a moment so that the "-- (insert) --" message is displayed
+ call TermWait(buf, 50)
+ call term_sendkeys(buf, "\<C-C>")
+ call VerifyScreenDump(buf, 'Test_mode_updated_1', {})
+
+ call StopVimInTerminal(buf)
+endfunc
+
" Test for '[m', ']m', '[M' and ']M'
" Jumping to beginning and end of methods in Java-like languages
func Test_java_motion()
diff --git a/test/functional/legacy/messages_spec.lua b/test/functional/legacy/messages_spec.lua
index 41f3007b81..159cf7a551 100644
--- a/test/functional/legacy/messages_spec.lua
+++ b/test/functional/legacy/messages_spec.lua
@@ -402,6 +402,28 @@ describe('messages', function()
|
]])
end)
+
+ -- oldtest: Test_mode_updated_after_ctrl_c()
+ it('pressing Ctrl-C in i_CTRL-O', function()
+ feed('i<C-O>')
+ screen:expect([[
+ ^ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {2:-- (insert) --} |
+ ]])
+ feed('<C-C>')
+ screen:expect([[
+ ^ |
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ {1:~ }|
+ |
+ ]])
+ end)
end)
-- oldtest: Test_ask_yesno()