summaryrefslogtreecommitdiffstats
path: root/src/fold.c
diff options
context:
space:
mode:
authorShota Nozaki <emonkak@gmail.com>2024-01-03 19:18:43 +0100
committerChristian Brabandt <cb@256bit.org>2024-01-03 19:18:43 +0100
commit0689b870595c687a23e102913ce5037f65d03748 (patch)
tree168af75375f949bf0f26943894fe974349ea6e56 /src/fold.c
parentbf44b69d1f91d9778ae1887128c63d35d9a3d19b (diff)
patch 9.1.0002: a closing fold expr, may start a new foldv9.1.0002
Problem: a closing fold expression may unexpectedly start a new fold when it should end a fold (reported by Shota Nozaki) Solution: if a fold hasn't started yet, do not immediately start a new fold with level 1 (Shota Nozaki) fixes: #12768 closes: #13748 Signed-off-by: Shota Nozaki <emonkak@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/fold.c')
-rw-r--r--src/fold.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/fold.c b/src/fold.c
index be20991c7a..5c41ed1b05 100644
--- a/src/fold.c
+++ b/src/fold.c
@@ -3362,7 +3362,9 @@ foldlevelExpr(fline_T *flp)
break;
// "<1", "<2", .. : end a fold with a certain level
- case '<': flp->lvl_next = n - 1;
+ case '<': // To prevent an unexpected start of a new fold, the next
+ // level must not exceed the level of the current fold.
+ flp->lvl_next = MIN(flp->lvl, n - 1);
flp->end = n;
break;