mirror of
https://github.com/neovim/neovim.git
synced 2024-09-17 20:58:20 -04:00
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
8d02e5cf96
Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
9b5ab66678
commit
37d97e771e
@ -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) {
|
||||
|
@ -1756,4 +1756,25 @@ func Test_cursor_down_fold_eob()
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
" issue: #15455
|
||||
func Test_cursor_fold_marker_undo()
|
||||
new
|
||||
call setline(1, ['{{{', '', 'This is a Line', '', 'This is a Line', '', '}}}'])
|
||||
let &ul=&ul
|
||||
setl foldmethod=marker
|
||||
call cursor(2, 1)
|
||||
norm! zo1vjdu
|
||||
call assert_equal(1, foldlevel('.'))
|
||||
bwipe!
|
||||
new
|
||||
call setline(1, ['', '{{{', '', 'This is a Line', '', 'This is a Line', '', '}}}'])
|
||||
let &ul=&ul
|
||||
setl foldmethod=marker
|
||||
call cursor(3, 1)
|
||||
norm! zo
|
||||
norm! vjdu
|
||||
call assert_equal(1, foldlevel('.'))
|
||||
bwipe!
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
Loading…
Reference in New Issue
Block a user