mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 11:15:14 -07:00
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)
6b731886ca
This commit is contained in:
parent
1f1a65a9e4
commit
a1df7c5771
@ -775,7 +775,7 @@ void clearFolding(win_T *win)
|
||||
/// The changes in lines from top to bot (inclusive).
|
||||
void foldUpdate(win_T *wp, linenr_T top, linenr_T bot)
|
||||
{
|
||||
if (compl_busy || State & MODE_INSERT) {
|
||||
if (disable_fold_update || compl_busy || State & MODE_INSERT) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@ typedef struct foldinfo {
|
||||
|
||||
#define FOLDINFO_INIT { 0, 0, 0, 0 }
|
||||
|
||||
EXTERN int disable_fold_update INIT(= 0);
|
||||
|
||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||
# include "fold.h.generated.h"
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user