fix(float): "Not enough room" error for 1-line float #25192

Problem: set winbar on a floating window which only have one row will
cause crash.

Solution: when new floating window only have one room don't copy winbar
from target window"

Fix #19464
This commit is contained in:
glepnir
2025-02-14 21:28:51 +08:00
committed by GitHub
parent dc33879dc2
commit cff5fa49fc
2 changed files with 36 additions and 0 deletions

View File

@@ -22,6 +22,7 @@
#include "nvim/move.h"
#include "nvim/option.h"
#include "nvim/option_defs.h"
#include "nvim/option_vars.h"
#include "nvim/optionstr.h"
#include "nvim/pos_defs.h"
#include "nvim/strings.h"
@@ -65,6 +66,12 @@ win_T *win_new_float(win_T *wp, bool last, WinConfig fconfig, Error *err)
}
wp = win_alloc(tp_last, false);
win_init(wp, curwin, 0);
if (wp->w_p_wbr != NULL && fconfig.height == 1) {
if (wp->w_p_wbr != empty_string_option) {
free_string_option(wp->w_p_wbr);
}
wp->w_p_wbr = empty_string_option;
}
} else {
assert(!last);
assert(!wp->w_floating);