From b4e3461e3fdfaa7d330ebe546cb75620a23ab54c Mon Sep 17 00:00:00 2001 From: Sean Dewar <6256228+seandewar@users.noreply.github.com> Date: Sat, 14 Mar 2026 09:18:21 +0000 Subject: [PATCH] fix(window): don't leak fold memory with style=minimal #38287 Problem: discarding saved option values in the WinInfo of closed style=minimal windows leaks memory. Solution: also free the nested folds. --- src/nvim/window.c | 1 + test/functional/api/window_spec.lua | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/src/nvim/window.c b/src/nvim/window.c index ed811fafb9..bdc3234532 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -5565,6 +5565,7 @@ void win_free(win_T *wp, tabpage_T *tp) // Discard saved options if the style is minimal. if (wp->w_config.style == kWinStyleMinimal && wip_wp->wi_optset) { clear_winopt(&wip_wp->wi_opt); + deleteFoldRecurse(buf, &wip_wp->wi_folds); wip_wp->wi_optset = false; } // If there already is an entry with "wi_win" set to NULL, only diff --git a/test/functional/api/window_spec.lua b/test/functional/api/window_spec.lua index 119b55f9a3..62cc514058 100644 --- a/test/functional/api/window_spec.lua +++ b/test/functional/api/window_spec.lua @@ -3650,5 +3650,11 @@ describe('API/win', function() eq(1, eval('&number')) eq(1, eval('&rightleft')) -- unrelated option unaffected end) + + it('minimal style does not leak WinInfo fold memory', function() + feed('zfG') + api.nvim_open_win(0, true, { split = 'below', style = 'minimal' }) + command('quit') + end) end) end)