Skip to content

Commit 6ba3ec1

Browse files
committed
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 #3009)
1 parent 43dee18 commit 6ba3ec1

4 files changed

Lines changed: 24 additions & 10 deletions

File tree

src/edit.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,7 +1704,12 @@ ins_redraw(
17041704
#endif
17051705
)
17061706
{
1707+
aco_save_T aco;
1708+
1709+
// save and restore curwin and curbuf, in case the autocmd changes them
1710+
aucmd_prepbuf(&aco, curbuf);
17071711
apply_autocmds(EVENT_TEXTCHANGEDI, NULL, NULL, FALSE, curbuf);
1712+
aucmd_restbuf(&aco);
17081713
curbuf->b_last_changedtick = CHANGEDTICK(curbuf);
17091714
}
17101715

@@ -1716,7 +1721,12 @@ ins_redraw(
17161721
&& curbuf->b_last_changedtick_pum != CHANGEDTICK(curbuf)
17171722
&& pum_visible())
17181723
{
1724+
aco_save_T aco;
1725+
1726+
// save and restore curwin and curbuf, in case the autocmd changes them
1727+
aucmd_prepbuf(&aco, curbuf);
17191728
apply_autocmds(EVENT_TEXTCHANGEDP, NULL, NULL, FALSE, curbuf);
1729+
aucmd_restbuf(&aco);
17201730
curbuf->b_last_changedtick_pum = CHANGEDTICK(curbuf);
17211731
}
17221732
#endif

src/proto/screen.pro

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ void status_redraw_curbuf(void);
2525
void redraw_statuslines(void);
2626
void win_redraw_last_status(frame_T *frp);
2727
void win_redr_status_matches(expand_T *xp, int num_matches, char_u **matches, int match, int showtail);
28-
void win_redr_status(win_T *wp);
2928
int stl_connected(win_T *wp);
3029
int get_keymap_str(win_T *wp, char_u *fmt, char_u *buf, int len);
3130
void screen_putchar(int c, int row, int col, int attr);

src/screen.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ static int redrawing_for_callback = 0;
125125
static schar_T *current_ScreenLine;
126126

127127
static void win_update(win_T *wp);
128+
static void win_redr_status(win_T *wp, int ignore_pum);
128129
static void win_draw_end(win_T *wp, int c1, int c2, int row, int endrow, hlf_T hl);
129130
#ifdef FEAT_FOLDING
130131
static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T lnum, int row);
@@ -774,7 +775,7 @@ update_screen(int type_arg)
774775
if (wp->w_redr_status)
775776
{
776777
cursor_off();
777-
win_redr_status(wp);
778+
win_redr_status(wp, TRUE); // any popup menu will be redrawn below
778779
}
779780
}
780781
#if defined(FEAT_SEARCH_EXTRA)
@@ -1030,7 +1031,7 @@ update_debug_sign(buf_T *buf, linenr_T lnum)
10301031
if (wp->w_redr_type != 0)
10311032
win_update(wp);
10321033
if (wp->w_redr_status)
1033-
win_redr_status(wp);
1034+
win_redr_status(wp, FALSE);
10341035
}
10351036

10361037
update_finish();
@@ -1074,7 +1075,7 @@ updateWindow(win_T *wp)
10741075
|| *p_stl != NUL || *wp->w_p_stl != NUL
10751076
# endif
10761077
)
1077-
win_redr_status(wp);
1078+
win_redr_status(wp, FALSE);
10781079

10791080
update_finish();
10801081
}
@@ -6535,7 +6536,7 @@ redraw_statuslines(void)
65356536

65366537
FOR_ALL_WINDOWS(wp)
65376538
if (wp->w_redr_status)
6538-
win_redr_status(wp);
6539+
win_redr_status(wp, FALSE);
65396540
if (redraw_tabline)
65406541
draw_tabline();
65416542
}
@@ -6864,9 +6865,11 @@ win_redr_status_matches(
68646865
* Redraw the status line of window wp.
68656866
*
68666867
* If inversion is possible we use it. Else '=' characters are used.
6868+
* If "ignore_pum" is TRUE, also redraw statusline when the popup menu is
6869+
* displayed.
68676870
*/
6868-
void
6869-
win_redr_status(win_T *wp)
6871+
static void
6872+
win_redr_status(win_T *wp, int ignore_pum)
68706873
{
68716874
int row;
68726875
char_u *p;
@@ -6890,9 +6893,9 @@ win_redr_status(win_T *wp)
68906893
}
68916894
else if (!redrawing()
68926895
#ifdef FEAT_INS_EXPAND
6893-
/* don't update status line when popup menu is visible and may be
6894-
* drawn over it */
6895-
|| pum_visible()
6896+
// don't update status line when popup menu is visible and may be
6897+
// drawn over it, unless it will be redrawn later
6898+
|| (!ignore_pum && pum_visible())
68966899
#endif
68976900
)
68986901
{

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,8 @@ static char *(features[]) =
761761

762762
static int included_patches[] =
763763
{ /* Add new patch number below this line */
764+
/**/
765+
57,
764766
/**/
765767
56,
766768
/**/

0 commit comments

Comments
 (0)