mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 14:08:32 +00:00
vim-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)
Reset and save `cmdwin_old_curwin` in a similar fashion.
Apply suitable changes for API functions and add Lua tests.
988f74311c
This commit is contained in:
@@ -4326,9 +4326,10 @@ static int open_cmdwin(void)
|
||||
// Don't let quitting the More prompt make this fail.
|
||||
got_int = false;
|
||||
|
||||
// Set "cmdwin_type" before any autocommands may mess things up.
|
||||
// Set "cmdwin_..." variables before any autocommands may mess things up.
|
||||
cmdwin_type = get_cmdline_type();
|
||||
cmdwin_level = ccline.level;
|
||||
cmdwin_win = curwin;
|
||||
cmdwin_old_curwin = old_curwin;
|
||||
|
||||
// Create empty command-line buffer.
|
||||
@@ -4337,9 +4338,12 @@ static int open_cmdwin(void)
|
||||
win_close(curwin, true, false);
|
||||
ga_clear(&winsizes);
|
||||
cmdwin_type = 0;
|
||||
cmdwin_win = NULL;
|
||||
cmdwin_old_curwin = NULL;
|
||||
return Ctrl_C;
|
||||
}
|
||||
cmdwin_buf = curbuf;
|
||||
|
||||
// Command-line buffer has bufhidden=wipe, unlike a true "scratch" buffer.
|
||||
set_option_value_give_err(kOptBufhidden, STATIC_CSTR_AS_OPTVAL("wipe"), OPT_LOCAL);
|
||||
curbuf->b_p_ma = true;
|
||||
@@ -4434,6 +4438,8 @@ static int open_cmdwin(void)
|
||||
|
||||
cmdwin_type = 0;
|
||||
cmdwin_level = 0;
|
||||
cmdwin_buf = NULL;
|
||||
cmdwin_win = NULL;
|
||||
cmdwin_old_curwin = NULL;
|
||||
|
||||
exmode_active = save_exmode;
|
||||
|
Reference in New Issue
Block a user