diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-03-30 21:41:03 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-03-31 10:05:26 +0800 |
commit | d5dee83552033506a308cac999a8c9f08e98e6b1 (patch) | |
tree | 7bf12442faf6d9a22f3ce96c2369a02d7879d85f | |
parent | e2247c0baa78570f7cb81695c28394ce0be73825 (diff) | |
download | rneovim-d5dee83552033506a308cac999a8c9f08e98e6b1.tar.gz rneovim-d5dee83552033506a308cac999a8c9f08e98e6b1.tar.bz2 rneovim-d5dee83552033506a308cac999a8c9f08e98e6b1.zip |
vim-patch:8.2.4156: fileinfo message overwrites echo'ed message
Problem: Fileinfo message overwrites echo'ed message.
Solution: Reset need_fileinfo when displaying a message. (Rob Pilling,
closes vim/vim#9569)
https://github.com/vim/vim/commit/726f7f91fd17e3e7eb39614a20d10ea83c134df0
-rw-r--r-- | src/nvim/message.c | 8 | ||||
-rw-r--r-- | src/nvim/testdir/test_messages.vim | 32 | ||||
-rw-r--r-- | test/functional/legacy/messages_spec.lua | 31 |
3 files changed, 69 insertions, 2 deletions
diff --git a/src/nvim/message.c b/src/nvim/message.c index 3ad38f7b77..6708001495 100644 --- a/src/nvim/message.c +++ b/src/nvim/message.c @@ -327,11 +327,12 @@ bool msg_attr_keep(const char *s, int attr, bool keep, bool multiline) } retval = msg_end(); - if (keep && retval && vim_strsize((char_u *)s) < (Rows - cmdline_row - 1) - * Columns + sc_col) { + if (keep && retval && vim_strsize((char_u *)s) < (Rows - cmdline_row - 1) * Columns + sc_col) { set_keep_msg((char *)s, 0); } + need_fileinfo = false; + xfree(buf); --entered; return retval; @@ -1355,6 +1356,7 @@ void msg_start(void) if (!msg_silent) { XFREE_CLEAR(keep_msg); // don't display old message now + need_fileinfo = false; } if (need_clr_eos) { @@ -2026,6 +2028,8 @@ void msg_puts_attr_len(const char *const str, const ptrdiff_t len, int attr) if (!msg_use_printf() || (headless_mode && default_grid.chars)) { msg_puts_display((const char_u *)str, len, attr, false); } + + need_fileinfo = false; } /// Print a formatted message diff --git a/src/nvim/testdir/test_messages.vim b/src/nvim/testdir/test_messages.vim index 65de0bb169..f8c6ee78e6 100644 --- a/src/nvim/testdir/test_messages.vim +++ b/src/nvim/testdir/test_messages.vim @@ -135,3 +135,35 @@ func Test_echo_string_partial() call assert_equal("function('CountSpaces', [{'ccccccccccc': ['ab', 'cd'], 'aaaaaaaaaaa': v:false, 'bbbbbbbbbbbb': ''}])", string(function('CountSpaces', [#{aaaaaaaaaaa: v:false, bbbbbbbbbbbb: '', ccccccccccc: ['ab', 'cd']}]))) endfunc +" Message output was previously overwritten by the fileinfo display, shown +" when switching buffers. If a buffer is switched to, then a message if +" echoed, we should show the message, rather than overwriting it with +" fileinfo. +func Test_fileinfo_after_echo() + CheckScreendump + + let content =<< trim END + file a.txt + + hide edit b.txt + call setline(1, "hi") + setlocal modified + + hide buffer a.txt + + set updatetime=1 + autocmd CursorHold * b b.txt | w | echo "'b' written" + END + + call writefile(content, 'Xtest_fileinfo_after_echo') + let buf = RunVimInTerminal('-S Xtest_fileinfo_after_echo', #{rows: 6}) + call VerifyScreenDump(buf, 'Test_fileinfo_after_echo', {}) + + call term_sendkeys(buf, ":q\<CR>") + + " clean up + call StopVimInTerminal(buf) + call delete('Xtest_fileinfo_after_echo') +endfunc + +" vim: shiftwidth=2 sts=2 expandtab diff --git a/test/functional/legacy/messages_spec.lua b/test/functional/legacy/messages_spec.lua index 330d70e7d4..335b269ad7 100644 --- a/test/functional/legacy/messages_spec.lua +++ b/test/functional/legacy/messages_spec.lua @@ -2,6 +2,7 @@ local helpers = require('test.functional.helpers')(after_each) local Screen = require('test.functional.ui.screen') local clear = helpers.clear local command = helpers.command +local exec = helpers.exec local feed = helpers.feed before_each(clear) @@ -35,4 +36,34 @@ describe('messages', function() | ]]) end) + + it('fileinfo does not overwrite echo message vim-patch:8.2.4156', function() + local screen = Screen.new(40, 6) + screen:set_default_attr_ids({ + [1] = {bold = true, foreground = Screen.colors.Blue}, -- NonText + }) + screen:attach() + exec([[ + set shortmess-=F + + file a.txt + + hide edit b.txt + call setline(1, "hi") + setlocal modified + + hide buffer a.txt + + set updatetime=1 + autocmd CursorHold * b b.txt | w | echo "'b' written" + ]]) + screen:expect([[ + ^hi | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + 'b' written | + ]]) + end) end) |