diff --git a/src/nvim/message.c b/src/nvim/message.c index 10b90bde29..89e8e4c632 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -1576,7 +1576,7 @@ int msg_outtrans_len(const char *msgstr, int len, int attr) // 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) { + if (msg_silent == 0 && len > 0 && msg_row >= cmdline_row && msg_col == 0) { clear_cmdline = false; mode_displayed = false; } diff --git a/test/functional/legacy/messages_spec.lua b/test/functional/legacy/messages_spec.lua index 2f3693b5ad..2ab946ccc7 100644 --- a/test/functional/legacy/messages_spec.lua +++ b/test/functional/legacy/messages_spec.lua @@ -89,6 +89,34 @@ describe('messages', function() ]]) end) + -- oldtest: Test_mode_cleared_after_silent_message() + it('mode is cleared properly after slient message', function() + screen = Screen.new(60, 10) + screen:attach() + exec([[ + edit XsilentMessageMode.txt + call setline(1, 'foobar') + autocmd TextChanged * silent update + ]]) + finally(function() + os.remove('XsilentMessageMode.txt') + end) + + feed('v') + screen:expect([[ + ^foobar | + {1:~ }|*8 + {5:-- VISUAL --} | + ]]) + + feed('d') + screen:expect([[ + ^oobar | + {1:~ }|*8 + | + ]]) + end) + describe('more prompt', function() before_each(function() command('set more') diff --git a/test/old/testdir/test_messages.vim b/test/old/testdir/test_messages.vim index ac5184645f..8836071ac1 100644 --- a/test/old/testdir/test_messages.vim +++ b/test/old/testdir/test_messages.vim @@ -386,6 +386,29 @@ func Test_message_not_cleared_after_mode() call StopVimInTerminal(buf) endfunc +func Test_mode_cleared_after_silent_message() + CheckRunVimInTerminal + + let lines =<< trim END + edit XsilentMessageMode.txt + call setline(1, 'foobar') + autocmd TextChanged * silent update + END + call writefile(lines, 'XsilentMessageMode', 'D') + let buf = RunVimInTerminal('-S XsilentMessageMode', {'rows': 10}) + + call term_sendkeys(buf, 'v') + call TermWait(buf) + call VerifyScreenDump(buf, 'Test_mode_cleared_after_silent_message_1', {}) + + call term_sendkeys(buf, 'd') + call TermWait(buf) + call VerifyScreenDump(buf, 'Test_mode_cleared_after_silent_message_2', {}) + + call StopVimInTerminal(buf) + call delete('XsilentMessageMode.txt') +endfunc + " Test verbose message before echo command func Test_echo_verbose_system() CheckRunVimInTerminal