mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 22:18:33 +00:00
fix(inccommand): avoid crash if callback changes inccommand option (#18830)
clang: Result of operation is garbage or undefined clang: Uninitialized argument value Also check for == 's' instead of != 'n' as it is more straightforward. Also fix another unrelated PVS warning: PVS/V1071: Return value of win_comp_pos() is not always used
This commit is contained in:
@@ -2413,6 +2413,7 @@ static void cmdpreview_show(CommandLineState *s)
|
||||
int save_w_p_cuc = curwin->w_p_cuc;
|
||||
bool save_hls = p_hls;
|
||||
varnumber_T save_changedtick = buf_get_changedtick(curbuf);
|
||||
bool icm_split = *p_icm == 's'; // inccommand=split
|
||||
buf_T *cmdpreview_buf;
|
||||
win_T *cmdpreview_win;
|
||||
cmdmod_T save_cmdmod = cmdmod;
|
||||
@@ -2433,7 +2434,7 @@ static void cmdpreview_show(CommandLineState *s)
|
||||
cmdmod.noswapfile = true; // Disable swap for preview buffer
|
||||
|
||||
// Open preview buffer if inccommand=split.
|
||||
if (*p_icm == 'n') {
|
||||
if (!icm_split) {
|
||||
cmdpreview_bufnr = 0;
|
||||
} else if ((cmdpreview_buf = cmdpreview_open_buf()) == NULL) {
|
||||
abort();
|
||||
@@ -2456,7 +2457,7 @@ static void cmdpreview_show(CommandLineState *s)
|
||||
}
|
||||
|
||||
// If inccommand=split and preview callback returns 2, open preview window.
|
||||
if (*p_icm != 'n' && cmdpreview_type == 2
|
||||
if (icm_split && cmdpreview_type == 2
|
||||
&& (cmdpreview_win = cmdpreview_open_win(cmdpreview_buf)) == NULL) {
|
||||
abort();
|
||||
}
|
||||
@@ -2470,7 +2471,7 @@ static void cmdpreview_show(CommandLineState *s)
|
||||
}
|
||||
|
||||
// Close preview window if it's open.
|
||||
if (*p_icm != 'n' && cmdpreview_type == 2 && cmdpreview_win != NULL) {
|
||||
if (icm_split && cmdpreview_type == 2 && cmdpreview_win != NULL) {
|
||||
cmdpreview_close_win();
|
||||
}
|
||||
// Clear preview highlights.
|
||||
|
Reference in New Issue
Block a user