diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-05-21 21:41:12 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2022-05-22 06:41:31 +0800 |
commit | a1df7c5771aec0a52ed86bf89277372a1a2e4b37 (patch) | |
tree | d40354435c4c8114a3d9d38711e374ff990f2835 /src/nvim/ops.c | |
parent | 1f1a65a9e4c602cd80458b213c28eadbdb5b1de1 (diff) | |
download | rneovim-a1df7c5771aec0a52ed86bf89277372a1a2e4b37.tar.gz rneovim-a1df7c5771aec0a52ed86bf89277372a1a2e4b37.tar.bz2 rneovim-a1df7c5771aec0a52ed86bf89277372a1a2e4b37.zip |
vim-patch:8.1.0535: increment/decrement might get interrupted by updating folds
Problem: Increment/decrement might get interrupted by updating folds.
Solution: Disable fold updating for a moment. (Christian Brabandt,
closes vim/vim#3599)
https://github.com/vim/vim/commit/6b731886ca94d66b9bdedfb7e603af44a6400399
Diffstat (limited to 'src/nvim/ops.c')
-rw-r--r-- | src/nvim/ops.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c index c3d7742307..0be49aaad4 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -4911,12 +4911,19 @@ void op_addsub(oparg_T *oap, linenr_T Prenum1, bool g_cmd) ssize_t change_cnt = 0; linenr_T amount = Prenum1; + // do_addsub() might trigger re-evaluation of 'foldexpr' halfway, when the + // buffer is not completly updated yet. Postpone updating folds until before + // the call to changed_lines(). + disable_fold_update++; + if (!VIsual_active) { pos = curwin->w_cursor; if (u_save_cursor() == FAIL) { + disable_fold_update--; return; } change_cnt = do_addsub(oap->op_type, &pos, 0, amount); + disable_fold_update--; if (change_cnt) { changed_lines(pos.lnum, 0, pos.lnum + 1, 0L, true); } @@ -4927,6 +4934,7 @@ void op_addsub(oparg_T *oap, linenr_T Prenum1, bool g_cmd) if (u_save((linenr_T)(oap->start.lnum - 1), (linenr_T)(oap->end.lnum + 1)) == FAIL) { + disable_fold_update--; return; } @@ -4973,6 +4981,8 @@ void op_addsub(oparg_T *oap, linenr_T Prenum1, bool g_cmd) amount += Prenum1; } } + + disable_fold_update--; if (change_cnt) { changed_lines(oap->start.lnum, 0, oap->end.lnum + 1, 0L, true); } |