I noticed after upgrading my Vim installation that messages from my plugins
were appearing in odd places. I finally had the time to look into it and
isolate the issue.
Patch 7.4.1696 introduced the "clearmode()" function. The ":stopinsert"
command invokes this function to clear the "-- INSERT --" indicator from the
bottom of the screen.
The "clearmode()" function will sometimes disturb the flow of Vim messages
because it calls a function that changes the coordinates ("msg_col" and
"msg_row") for message output. This effect is visible when the 'cmdheight'
setting is higher than 1.
Reproduce the issue as follows (using "vim -u NONE"):
1 :set cmdheight=2
2 :vnew
3 :autocmd BufEnter <buffer> stopinsert
4 :wincmd w | echo 'test'
5 :wincmd w | echo 'test'
Note that on #4 'test' replaced the entered command, but not on #5. The
behavior of #4 is what was seen in Vim prior to patch 7.4.1696.
A simpler series of commands to observe the problem is:
1 :set cmdheight=2
2 :stopinsert | echo 'test'
Note that 'test' should have overwritten the command.
The patch that is attached to this email modifies "clearmode()" to save and
restore the message output coordinates so that the flow of message output is
not disturbed whenever the mode indicator is cleared from the screen.
As usual, a test is included in the patch to ensure that this problem
remains fixed in future versions of Vim.
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
>From a4c10e42d533785c85382497f4ce757b36ee573f Mon Sep 17 00:00:00 2001
From: Jason Franklin <[email protected]>
Date: Fri, 18 May 2018 16:03:22 -0400
Subject: [PATCH] Prevent clearmode() from breaking message output
---
src/screen.c | 9 +++++++++
src/testdir/test_messages.vim | 21 +++++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/src/screen.c b/src/screen.c
index 841dc18..cd08af7 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -10485,10 +10485,19 @@ unshowmode(int force)
void
clearmode(void)
{
+ int msg_x;
+ int msg_y;
+
+ msg_x = msg_col;
+ msg_y = msg_row;
+
msg_pos_mode();
if (Recording)
recording_mode(HL_ATTR(HLF_CM));
msg_clr_eos();
+
+ msg_col = msg_x;
+ msg_row = msg_y;
}
static void
diff --git a/src/testdir/test_messages.vim b/src/testdir/test_messages.vim
index 188406e..384d2aa 100644
--- a/src/testdir/test_messages.vim
+++ b/src/testdir/test_messages.vim
@@ -38,3 +38,24 @@ function Test_messages()
let &more = oldmore
endtry
endfunction
+
+" Patch 7.4.1696 defined the "clearmode()" command for clearing the mode
+" indicator (e.g., "-- INSERT --") when ":stopinsert" is invoked. Message
+" output could then be disturbed when 'cmdheight' was greater than one.
+" This test ensures that the bugfix for this issue remains in place.
+function! Test_stopinsert_does_not_break_message_output()
+ set cmdheight=2
+ redraw!
+
+ stopinsert | echo 'test echo'
+ call assert_equal(116, screenchar(&lines - 1, 1))
+ call assert_equal(32, screenchar(&lines, 1))
+ redraw!
+
+ stopinsert | echomsg 'test echomsg'
+ call assert_equal(116, screenchar(&lines - 1, 1))
+ call assert_equal(32, screenchar(&lines, 1))
+ redraw!
+
+ set cmdheight&
+endfunction
--
2.7.4