diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-06-16 09:20:41 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-16 09:20:41 +0800 |
commit | 8376e8700b3d4f8ab96751612c3f4439a43b06f4 (patch) | |
tree | fc1d9c844283da12dfe91b716f97976b66bcfabd | |
parent | ddba917efee26229d77f86d14a9f62dcfdc822b8 (diff) | |
parent | 11060793d6544e893f31d65e8f964453c463407c (diff) | |
download | rneovim-8376e8700b3d4f8ab96751612c3f4439a43b06f4.tar.gz rneovim-8376e8700b3d4f8ab96751612c3f4439a43b06f4.tar.bz2 rneovim-8376e8700b3d4f8ab96751612c3f4439a43b06f4.zip |
Merge pull request #24037 from zeertzjq/vim-9.0.1634
vim-patch:9.0.{1634,1635}: message is cleared when removing mode message
-rw-r--r-- | src/nvim/message.c | 7 | ||||
-rw-r--r-- | test/functional/legacy/messages_spec.lua | 65 | ||||
-rw-r--r-- | test/functional/terminal/tui_spec.lua | 2 | ||||
-rw-r--r-- | test/old/testdir/test_messages.vim | 35 |
4 files changed, 108 insertions, 1 deletions
diff --git a/src/nvim/message.c b/src/nvim/message.c index 1cb4a3cbf4..0064f0358b 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1560,6 +1560,13 @@ int msg_outtrans_len_attr(const char *msgstr, int len, int attr) attr &= ~MSG_HIST; } + // When drawing over the command line no need to clear it later or remove + // the mode message. + if (msg_row >= cmdline_row && msg_col == 0) { + clear_cmdline = false; + mode_displayed = false; + } + // If the string starts with a composing character first draw a space on // which the composing char can be drawn. if (utf_iscomposing(utf_ptr2char(msgstr))) { diff --git a/test/functional/legacy/messages_spec.lua b/test/functional/legacy/messages_spec.lua index 794676153c..a604e68822 100644 --- a/test/functional/legacy/messages_spec.lua +++ b/test/functional/legacy/messages_spec.lua @@ -49,6 +49,71 @@ describe('messages', function() ]]) end) + -- oldtest: Test_message_not_cleared_after_mode() + it('clearing mode does not remove message', function() + screen = Screen.new(60, 10) + screen:set_default_attr_ids({ + [0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + [1] = {background = Screen.colors.Red, foreground = Screen.colors.White}, -- ErrorMsg + }) + screen:attach() + exec([[ + nmap <silent> gx :call DebugSilent('normal')<CR> + vmap <silent> gx :call DebugSilent('visual')<CR> + function DebugSilent(arg) + echomsg "from DebugSilent" a:arg + endfunction + set showmode + set cmdheight=1 + call setline(1, ['one', 'NoSuchFile', 'three']) + ]]) + + feed('gx') + screen:expect([[ + ^one | + NoSuchFile | + three | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + from DebugSilent normal | + ]]) + + -- removing the mode message used to also clear the intended message + feed('vEgx') + screen:expect([[ + ^one | + NoSuchFile | + three | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + from DebugSilent visual | + ]]) + + -- removing the mode message used to also clear the error message + command('set cmdheight=2') + feed('2GvEgf') + screen:expect([[ + one | + NoSuchFil^e | + three | + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + {0:~ }| + from DebugSilent visual | + {1:E447: Can't find file "NoSuchFile" in path} | + ]]) + end) + describe('more prompt', function() before_each(function() command('set more') diff --git a/test/functional/terminal/tui_spec.lua b/test/functional/terminal/tui_spec.lua index 7723b6c7e7..b1836f2e4d 100644 --- a/test/functional/terminal/tui_spec.lua +++ b/test/functional/terminal/tui_spec.lua @@ -2475,7 +2475,7 @@ describe("TUI as a client", function() -- grid smaller than containing terminal window is cleared properly feed_data(":call setline(1,['a'->repeat(&columns)]->repeat(&lines))\n") - feed_data("0:set lines=2\n") + feed_data("0:set lines=3\n") screen_server:expect{grid=[[ {1:a}aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa| {5:[No Name] [+] }| diff --git a/test/old/testdir/test_messages.vim b/test/old/testdir/test_messages.vim index a20571807b..31c8b9942b 100644 --- a/test/old/testdir/test_messages.vim +++ b/test/old/testdir/test_messages.vim @@ -341,6 +341,41 @@ func Test_message_more_scrollback() call StopVimInTerminal(buf) endfunc +func Test_message_not_cleared_after_mode() + CheckRunVimInTerminal + + let lines =<< trim END + nmap <silent> gx :call DebugSilent('normal')<CR> + vmap <silent> gx :call DebugSilent('visual')<CR> + function DebugSilent(arg) + echomsg "from DebugSilent" a:arg + endfunction + set showmode + set cmdheight=1 + call test_settime(1) + call setline(1, ['one', 'NoSuchFile', 'three']) + END + call writefile(lines, 'XmessageMode', 'D') + let buf = RunVimInTerminal('-S XmessageMode', {'rows': 10}) + + call term_sendkeys(buf, 'gx') + call TermWait(buf) + call VerifyScreenDump(buf, 'Test_message_not_cleared_after_mode_1', {}) + + " removing the mode message used to also clear the intended message + call term_sendkeys(buf, 'vEgx') + call TermWait(buf) + call VerifyScreenDump(buf, 'Test_message_not_cleared_after_mode_2', {}) + + " removing the mode message used to also clear the error message + call term_sendkeys(buf, ":set cmdheight=2\<CR>") + call term_sendkeys(buf, '2GvEgf') + call TermWait(buf) + call VerifyScreenDump(buf, 'Test_message_not_cleared_after_mode_3', {}) + + call StopVimInTerminal(buf) +endfunc + " Test verbose message before echo command func Test_echo_verbose_system() CheckRunVimInTerminal |