From: Igor Mikushkin Date: Wed, 29 Jul 2026 18:53:08 +0000 (+0000) Subject: patch 9.2.0874: fold size is compared against 'foldminlines' of the wrong window X-Git-Tag: v9.2.0874^0 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=773dc19f145744d65e0e920df57e6e3d33fd4591;p=thirdparty%2Fvim.git patch 9.2.0874: fold size is compared against 'foldminlines' of the wrong window Problem: checkSmall() compares the fold size of window "wp" against the current window's 'foldminlines'. A fold of another window, e.g. measured while it is redrawn, is judged by an unrelated option value. Solution: Use 'foldminlines' of the window containing the fold (Igor Mikushkin). closes: #20864 Co-authored-by: Claude Signed-off-by: Igor Mikushkin Signed-off-by: Christian Brabandt --- diff --git a/src/fold.c b/src/fold.c index 19c444c14c..04698429d6 100644 --- a/src/fold.c +++ b/src/fold.c @@ -1730,7 +1730,7 @@ checkSmall( // Mark any nested folds to maybe-small setSmallMaybe(&fp->fd_nested); - if (fp->fd_len > curwin->w_p_fml) + if (fp->fd_len > wp->w_p_fml) fp->fd_small = FALSE; else { @@ -1738,7 +1738,7 @@ checkSmall( for (n = 0; n < fp->fd_len; ++n) { count += plines_win_nofold(wp, fp->fd_top + lnum_off + n); - if (count > curwin->w_p_fml) + if (count > wp->w_p_fml) { fp->fd_small = FALSE; return; diff --git a/src/testdir/test_fold.vim b/src/testdir/test_fold.vim index d4b3a5093b..1c09719b13 100644 --- a/src/testdir/test_fold.vim +++ b/src/testdir/test_fold.vim @@ -2105,4 +2105,42 @@ func Test_cursor_fold_marker_undo() bwipe! endfunc +" The fold size must be compared against 'foldminlines' of the window that +" contains the fold, not of the current window. +func Test_foldminlines_per_window() + " Window with 'foldminlines'=5: its two-line fold stays displayed open. + new + setlocal foldenable foldmethod=manual foldminlines=5 + call setline(1, ['one', 'two', 'three', 'four']) + 2,3fold + call assert_equal(-1, foldclosed(2)) + let winid = win_getid() + + " Split; only the new current window gets 'foldminlines'=0. setline() + " invalidates the fold sizes of both windows and measures them again right + " away, the other window's while this window is current. win_execute() + " below only reads that cached verdict, without measuring again. + split + setlocal foldminlines=0 + call setline(2, 'changed') + call assert_equal(2, foldclosed(2)) + call win_execute(winid, 'call assert_equal(-1, foldclosed(2))') + bwipe! + + " The same the other way around: 'foldminlines'=0 in the other window, so + " its fold must remain closed while the current window has a higher value. + new + setlocal foldenable foldmethod=manual foldminlines=0 + call setline(1, ['one', 'two', 'three', 'four']) + 2,3fold + call assert_equal(2, foldclosed(2)) + let winid = win_getid() + split + setlocal foldminlines=5 + call setline(2, 'changed') + call assert_equal(-1, foldclosed(2)) + call win_execute(winid, 'call assert_equal(2, foldclosed(2))') + bwipe! +endfunc + " vim: shiftwidth=2 sts=2 expandtab diff --git a/src/version.c b/src/version.c index 1f78ca0d85..9d2474d687 100644 --- a/src/version.c +++ b/src/version.c @@ -758,6 +758,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 874, /**/ 873, /**/