diff options
-rw-r--r-- | src/nvim/edit.c | 3 | ||||
-rw-r--r-- | src/nvim/fold.c | 13 | ||||
-rw-r--r-- | src/nvim/normal.c | 3 |
3 files changed, 15 insertions, 4 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c index 51c9fb1556..a0ae1a3e6b 100644 --- a/src/nvim/edit.c +++ b/src/nvim/edit.c @@ -462,8 +462,7 @@ static void insert_enter(InsertState *s) o_lnum = curwin->w_cursor.lnum; } - foldUpdateAll(curwin); - foldOpenCursor(); + foldUpdateAfterInsert(); if (s->cmdchar != 'r' && s->cmdchar != 'v') { apply_autocmds(EVENT_INSERTLEAVE, NULL, NULL, false, curbuf); } diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 70030b8525..c84d738cb4 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -788,6 +788,19 @@ void foldUpdate(win_T *wp, linenr_T top, linenr_T bot) } } +/// Updates folds when leaving insert-mode. +void foldUpdateAfterInsert(void) +{ + if (foldmethodIsManual(curwin) // foldmethod=manual: No need to update. + // These foldmethods are too slow, do not auto-update on insert-leave. + || foldmethodIsSyntax(curwin) || foldmethodIsExpr(curwin)) { + return; + } + + foldUpdateAll(curwin); + foldOpenCursor(); +} + /* foldUpdateAll() {{{2 */ /* * Update all lines in a window for folding. diff --git a/src/nvim/normal.c b/src/nvim/normal.c index 6dcbf50750..76e3829bee 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -5925,8 +5925,7 @@ static void nv_replace(cmdarg_T *cap) set_last_insert(cap->nchar); } - foldUpdateAll(curwin); - foldOpenCursor(); + foldUpdateAfterInsert(); } /* |