Commit: patch 9.2.0874: fold size is compared against 'foldminlines' of the wrong window
Christian Brabandt <[email protected]> Wed, 29 Jul 2026 21:15:03 +0200
| Newsgroups | gmane.editors.vim.devel |
|---|---|
| Message-ID | <[email protected]> |
patch 9.2.0874: fold size is compared against 'foldminlines' of the wrong window Commit: https://github.com/vim/vim/commit/773dc19f145744d65e0e920df57e6e3d33fd4591 Author: Igor Mikushkin <[email protected]> Date: Wed Jul 29 18:53:08 2026 +0000 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 <[email protected]> Signed-off-by: Igor Mikushkin <[email protected]> Signed-off-by: Christian Brabandt <[email protected]> diff --git a/src/fold.c b/src/fold.c index 19c444c14..04698429d 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 d4b3a5093..1c09719b1 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 1f78ca0d8..9d2474d68 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, /**/ -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1wp9k7-002uja-MY%40256bit.org.