aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Felice <jason.m.felice@gmail.com>2018-08-08 20:51:49 -0700
committerJason Felice <jason.m.felice@gmail.com>2018-08-09 16:46:01 -0700
commit0a8be9f8ef1e23a375b3a35ec06734f205cfd181 (patch)
tree2285602a55b0613b4091cfa7d0d867d023d57f55
parentcf9dd7a3f473c5d523e7f248bfc6f83904fff74b (diff)
downloadrneovim-0a8be9f8ef1e23a375b3a35ec06734f205cfd181.tar.gz
rneovim-0a8be9f8ef1e23a375b3a35ec06734f205cfd181.tar.bz2
rneovim-0a8be9f8ef1e23a375b3a35ec06734f205cfd181.zip
vim-patch:8.1.0057: popup menu displayed wrong when using autocmd
Problem: Popup menu displayed wrong when using autocmd. Solution: Use aucmd_prepbuf(). Force updating status line if the popup menu is going to be redrawn anyway. (Christian Brabandt, closes vim/vim#3009) https://github.com/vim/vim/commit/6ba3ec1bace67513a352326864cebc16b3c5bc56
-rw-r--r--src/nvim/edit.c14
-rw-r--r--src/nvim/screen.c12
2 files changed, 19 insertions, 7 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 0d99aa8fb2..7279110444 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -1390,7 +1390,12 @@ ins_redraw (
if (ready && has_event(EVENT_TEXTCHANGEDI)
&& curbuf->b_last_changedtick != buf_get_changedtick(curbuf)
&& !pum_visible()) {
+ aco_save_T aco;
+
+ // save and restore curwin and curbuf, in case the autocmd changes them
+ aucmd_prepbuf(&aco, curbuf);
apply_autocmds(EVENT_TEXTCHANGEDI, NULL, NULL, false, curbuf);
+ aucmd_restbuf(&aco);
curbuf->b_last_changedtick = buf_get_changedtick(curbuf);
}
@@ -1400,8 +1405,13 @@ ins_redraw (
if (ready && has_event(EVENT_TEXTCHANGEDP)
&& curbuf->b_last_changedtick_pum != buf_get_changedtick(curbuf)
&& pum_visible()) {
- apply_autocmds(EVENT_TEXTCHANGEDP, NULL, NULL, false, curbuf);
- curbuf->b_last_changedtick_pum = buf_get_changedtick(curbuf);
+ aco_save_T aco;
+
+ // save and restore curwin and curbuf, in case the autocmd changes them
+ aucmd_prepbuf(&aco, curbuf);
+ apply_autocmds(EVENT_TEXTCHANGEDP, NULL, NULL, false, curbuf);
+ aucmd_restbuf(&aco);
+ curbuf->b_last_changedtick_pum = buf_get_changedtick(curbuf);
}
if (must_redraw)
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index f7fdc6060d..43ab9cd356 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -423,7 +423,7 @@ void update_screen(int type)
/* redraw status line after the window to minimize cursor movement */
if (wp->w_redr_status) {
- win_redr_status(wp);
+ win_redr_status(wp, true); // any popup menu will be redrawn below
}
}
end_search_hl();
@@ -589,7 +589,7 @@ void update_debug_sign(const buf_T *const buf, const linenr_T lnum)
win_update(wp);
}
if (wp->w_redr_status) {
- win_redr_status(wp);
+ win_redr_status(wp, false);
}
}
@@ -4542,7 +4542,7 @@ void redraw_statuslines(void)
{
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
if (wp->w_redr_status) {
- win_redr_status(wp);
+ win_redr_status(wp, false);
}
}
if (redraw_tabline)
@@ -4809,7 +4809,9 @@ win_redr_status_matches (
/// Redraw the status line of window `wp`.
///
/// If inversion is possible we use it. Else '=' characters are used.
-static void win_redr_status(win_T *wp)
+/// If "ignore_pum" is true, also redraw statusline when the popup menu is
+/// displayed.
+static void win_redr_status(win_T *wp, int ignore_pum)
{
int row;
char_u *p;
@@ -4832,7 +4834,7 @@ static void win_redr_status(win_T *wp)
if (wp->w_status_height == 0) {
// no status line, can only be last window
redraw_cmdline = true;
- } else if (!redrawing() || pum_drawn()) {
+ } else if (!redrawing() || (!ignore_pum && pum_drawn())) {
// Don't redraw right now, do it later. Don't update status line when
// popup menu is visible and may be drawn over it
wp->w_redr_status = true;