diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-08-12 06:52:31 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-11 22:52:31 +0000 |
commit | 37d97e771e9140746629bc3e67ad2dfbd39888c5 (patch) | |
tree | 63bc47309d4a49cd15f81e6e84741a98b359ad3e /src/nvim/fold.c | |
parent | 9b5ab66678f8efa1f5fe89205839fe053fe5efaf (diff) | |
download | rneovim-37d97e771e9140746629bc3e67ad2dfbd39888c5.tar.gz rneovim-37d97e771e9140746629bc3e67ad2dfbd39888c5.tar.bz2 rneovim-37d97e771e9140746629bc3e67ad2dfbd39888c5.zip |
vim-patch:9.1.0672: marker folds may get corrupted on undo (#30026)
Problem: marker folds may get corrupted on undo (Yousef Mohammed)
Solution: when adjusting folds, make sure that line1 is the lower limit
and line2 is the upper line limit. In particular, line2 should
not be able to get smaller than line1.
fixes: vim/vim#15455
closes: vim/vim#15466
https://github.com/vim/vim/commit/8d02e5cf961b06da5bc490ac5972bcbc252c4793
Co-authored-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/nvim/fold.c')
-rw-r--r-- | src/nvim/fold.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/nvim/fold.c b/src/nvim/fold.c index c8e6a25dbc..e7231c31ab 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -1336,6 +1336,9 @@ void deleteFoldRecurse(buf_T *bp, garray_T *gap) // foldMarkAdjust() {{{2 /// Update line numbers of folds for inserted/deleted lines. +/// +/// We are adjusting the folds in the range from line1 til line2, +/// make sure that line2 does not get smaller than line1 void foldMarkAdjust(win_T *wp, linenr_T line1, linenr_T line2, linenr_T amount, linenr_T amount_after) { @@ -1344,6 +1347,9 @@ void foldMarkAdjust(win_T *wp, linenr_T line1, linenr_T line2, linenr_T amount, if (amount == MAXLNUM && line2 >= line1 && line2 - line1 >= -amount_after) { line2 = line1 - amount_after - 1; } + if (line2 < line1) { + line2 = line1; + } // If appending a line in Insert mode, it should be included in the fold // just above the line. if ((State & MODE_INSERT) && amount == 1 && line2 == MAXLNUM) { |