From be01b361d8ff0e8bf8f93cdf4e4f1055ecd341c2 Mon Sep 17 00:00:00 2001 From: glepnir Date: Mon, 27 Jan 2025 23:52:27 +0800 Subject: fix(float): cannot set title/footer independently #31993 Problem: `nvim_win_set_config` cannot set the title and footer independently. When only one is given, the other is reset to the default of "left". Solution: Reuse existing title/footer value if not provided. --- src/nvim/api/win_config.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/nvim/api/win_config.c b/src/nvim/api/win_config.c index 225189a3f9..1132452faf 100644 --- a/src/nvim/api/win_config.c +++ b/src/nvim/api/win_config.c @@ -895,7 +895,7 @@ static void parse_bordertext(Object bordertext, BorderTextType bordertext_type, *is_present = true; } -static bool parse_bordertext_pos(String bordertext_pos, BorderTextType bordertext_type, +static bool parse_bordertext_pos(win_T *wp, String bordertext_pos, BorderTextType bordertext_type, WinConfig *fconfig, Error *err) { AlignTextPos *align; @@ -909,7 +909,9 @@ static bool parse_bordertext_pos(String bordertext_pos, BorderTextType bordertex } if (bordertext_pos.size == 0) { - *align = kAlignLeft; + if (!wp) { + *align = kAlignLeft; + } return true; } @@ -1250,7 +1252,7 @@ static bool parse_win_config(win_T *wp, Dict(win_config) *config, WinConfig *fco } // handles unset 'title_pos' same as empty string - if (!parse_bordertext_pos(config->title_pos, kBorderTextTitle, fconfig, err)) { + if (!parse_bordertext_pos(wp, config->title_pos, kBorderTextTitle, fconfig, err)) { goto fail; } } else { @@ -1277,7 +1279,7 @@ static bool parse_win_config(win_T *wp, Dict(win_config) *config, WinConfig *fco } // handles unset 'footer_pos' same as empty string - if (!parse_bordertext_pos(config->footer_pos, kBorderTextFooter, fconfig, err)) { + if (!parse_bordertext_pos(wp, config->footer_pos, kBorderTextFooter, fconfig, err)) { goto fail; } } else { -- cgit