fix(inccommand): improve preview buffer number handling (#27087)

This commit is contained in:
zeertzjq
2024-01-19 11:04:01 +08:00
committed by GitHub
parent 78b000c74d
commit ba9f86a9ce
3 changed files with 74 additions and 4 deletions

View File

@@ -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) {