From ba9f86a9cee58dc32ab875da1fd7eac9bc9e88d7 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 19 Jan 2024 11:04:01 +0800 Subject: fix(inccommand): improve preview buffer number handling (#27087) --- src/nvim/ex_getln.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index d10214b48f..2c5c291216 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -2277,6 +2277,7 @@ static buf_T *cmdpreview_open_buf(void) /// /// @return Pointer to command preview window if succeeded, NULL if failed. static win_T *cmdpreview_open_win(buf_T *cmdpreview_buf) + FUNC_ATTR_NONNULL_ALL { win_T *save_curwin = curwin; @@ -2548,10 +2549,10 @@ static bool cmdpreview_may_show(CommandLineState *s) cmdpreview_prepare(&cpinfo); // Open preview buffer if inccommand=split. - if (!icm_split) { - cmdpreview_bufnr = 0; - } else if ((cmdpreview_buf = cmdpreview_open_buf()) == NULL) { - abort(); + if (icm_split && (cmdpreview_buf = cmdpreview_open_buf()) == NULL) { + // Failed to create preview buffer, so disable preview. + set_string_option_direct(kOptInccommand, "nosplit", 0, SID_NONE); + icm_split = false; } // Setup preview namespace if it's not already set. if (!cmdpreview_ns) { -- cgit