diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-05-22 21:03:22 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-22 21:03:22 +0800 |
commit | 70e3caec4a570e6ab1375aec98ebbfa1dd673961 (patch) | |
tree | b88c0c27dd4429b7c98091bb797e333566d6c35a | |
parent | e7b3fd8ad603ba064ce9457a8866430c436c3737 (diff) | |
download | rneovim-70e3caec4a570e6ab1375aec98ebbfa1dd673961.tar.gz rneovim-70e3caec4a570e6ab1375aec98ebbfa1dd673961.tar.bz2 rneovim-70e3caec4a570e6ab1375aec98ebbfa1dd673961.zip |
fix(folds): fix fold regression with :move (#18685)
-rw-r--r-- | src/nvim/ex_cmds.c | 6 | ||||
-rw-r--r-- | test/functional/ui/fold_spec.lua | 61 |
2 files changed, 67 insertions, 0 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 8369db7de1..ce3afba19b 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -971,7 +971,11 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest) */ last_line = curbuf->b_ml.ml_line_count; mark_adjust_nofold(line1, line2, last_line - line2, 0L, kExtmarkNOOP); + + disable_fold_update++; changed_lines(last_line - num_lines + 1, 0, last_line + 1, num_lines, false); + disable_fold_update--; + int line_off = 0; bcount_t byte_off = 0; if (dest >= line2) { @@ -1005,7 +1009,9 @@ int do_move(linenr_T line1, linenr_T line2, linenr_T dest) mark_adjust_nofold(last_line - num_lines + 1, last_line, -(last_line - dest - extra), 0L, kExtmarkNOOP); + disable_fold_update++; changed_lines(last_line - num_lines + 1, 0, last_line + 1, -extra, false); + disable_fold_update--; // send update regarding the new lines that were added buf_updates_send_changes(curbuf, dest + 1, num_lines, 0, true); diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index 9762805dee..394f2f5f49 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -1757,6 +1757,67 @@ describe("folded lines", function() end assert_alive() end) + + it('work correctly with :move #18668', function() + screen:try_resize(45, 12) + source([[ + set foldmethod=expr foldexpr=indent(v:lnum) + let content = ['', '', 'Line1', ' Line2', ' Line3', + \ 'Line4', ' Line5', ' Line6', + \ 'Line7', ' Line8', ' Line9'] + call append(0, content) + normal! zM + call cursor(4, 1) + move 2 + move 1 + ]]) + if multigrid then + screen:expect([[ + ## grid 1 + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [2:---------------------------------------------]| + [3:---------------------------------------------]| + ## grid 2 + | + {5:^+-- 2 lines: Line2··························}| + | + Line1 | + Line4 | + {5:+-- 2 lines: Line5··························}| + Line7 | + {5:+-- 2 lines: Line8··························}| + | + {1:~ }| + {1:~ }| + ## grid 3 + | + ]]) + else + screen:expect([[ + | + {5:^+-- 2 lines: Line2··························}| + | + Line1 | + Line4 | + {5:+-- 2 lines: Line5··························}| + Line7 | + {5:+-- 2 lines: Line8··························}| + | + {1:~ }| + {1:~ }| + | + ]]) + end + end) end describe("with ext_multigrid", function() |