0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

patch 9.1.0047: issues with temp curwin/buf while cmdwin is open

Problem:  Things that temporarily change/restore curwin/buf (e.g:
          win_execute, some autocmds) may break assumptions that
          curwin/buf is the cmdwin when "cmdwin_type != 0", causing
          issues.

Solution: Expose the cmdwin's real win/buf and check that instead. Also
          try to ensure these variables are NULL if "cmdwin_type == 0",
          allowing them to be used directly in most cases without
          checking cmdwin_type. (Sean Dewar)

Alternatively, we could ban win_execute in the cmdwin and audit all places that
temporarily change/restore curwin/buf, but I didn't notice any problems arising
from allowing this (standard cmdwin restrictions still apply, so things that may
actually break the cmdwin are still forbidden).

closes: #12819

Signed-off-by: Sean Dewar <seandewar@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
Sean Dewar
2023-08-16 14:17:36 +01:00
committed by Christian Brabandt
parent 4927110a43
commit 988f74311c
13 changed files with 67 additions and 13 deletions

View File

@@ -1696,7 +1696,7 @@ retnomove:
}
#if defined(FEAT_CLIPBOARD)
// Continue a modeless selection in another window.
if (cmdwin_type != 0 && row < curwin->w_winrow)
if (cmdwin_type != 0 && row < cmdwin_win->w_winrow)
return IN_OTHER_WIN;
#endif
#ifdef FEAT_PROP_POPUP
@@ -1824,7 +1824,7 @@ retnomove:
# ifdef FEAT_RIGHTLEFT
wp->w_p_rl ? col < wp->w_width - wp->w_p_fdc :
# endif
col >= wp->w_p_fdc + (cmdwin_type == 0 && wp == curwin ? 0 : 1)
col >= wp->w_p_fdc + (wp != cmdwin_win ? 0 : 1)
)
#endif
&& (flags & MOUSE_MAY_STOP_VIS))))
@@ -1832,7 +1832,7 @@ retnomove:
end_visual_mode_keep_button();
redraw_curbuf_later(UPD_INVERTED); // delete the inversion
}
if (cmdwin_type != 0 && wp != curwin)
if (cmdwin_type != 0 && wp != cmdwin_win)
{
// A click outside the command-line window: Use modeless
// selection if possible. Allow dragging the status lines.
@@ -1844,7 +1844,7 @@ retnomove:
#else
row = 0;
col += wp->w_wincol;
wp = curwin;
wp = cmdwin_win;
#endif
}
#if defined(FEAT_PROP_POPUP) && defined(FEAT_TERMINAL)
@@ -1937,7 +1937,7 @@ retnomove:
#if defined(FEAT_CLIPBOARD)
// Continue a modeless selection in another window.
if (cmdwin_type != 0 && row < curwin->w_winrow)
if (cmdwin_type != 0 && row < cmdwin_win->w_winrow)
return IN_OTHER_WIN;
#endif
#ifdef FEAT_PROP_POPUP
@@ -2075,7 +2075,7 @@ retnomove:
# ifdef FEAT_RIGHTLEFT
curwin->w_p_rl ? col < curwin->w_width - curwin->w_p_fdc :
# endif
col >= curwin->w_p_fdc + (cmdwin_type == 0 ? 0 : 1)
col >= curwin->w_p_fdc + (cmdwin_win != curwin ? 0 : 1)
)
mouse_char = ' ';
#endif