diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2019-11-16 12:31:46 -0500 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2019-11-16 16:40:24 -0500 |
commit | 7274f5c177d49660ed8c06998da402a09f5f31c6 (patch) | |
tree | 0d36f909049b31337fc3499270f741a04ef5674d /src | |
parent | d3ef88db63d8b060bc6eb4dc4dbccb48cfbfaf40 (diff) | |
download | rneovim-7274f5c177d49660ed8c06998da402a09f5f31c6.tar.gz rneovim-7274f5c177d49660ed8c06998da402a09f5f31c6.tar.bz2 rneovim-7274f5c177d49660ed8c06998da402a09f5f31c6.zip |
vim-patch:8.1.1922: in diff mode global operations can be very slow
Problem: In diff mode global operations can be very slow.
Solution: Do not call diff_redraw() many times, call it once when redrawing.
And also don't update folds multiple times.
https://github.com/vim/vim/commit/4f57eefe1e84b5a90e08474092ea6fc8825ad5c9
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/diff.c | 6 | ||||
-rw-r--r-- | src/nvim/fold.c | 5 | ||||
-rw-r--r-- | src/nvim/globals.h | 1 | ||||
-rw-r--r-- | src/nvim/screen.c | 5 |
4 files changed, 15 insertions, 2 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c index 313f77474d..0f916106a2 100644 --- a/src/nvim/diff.c +++ b/src/nvim/diff.c @@ -490,7 +490,8 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1, } if (tp == curtab) { - diff_redraw(true); + // Don't redraw right away, this updates the diffs, which can be slow. + need_diff_redraw = true; // Need to recompute the scroll binding, may remove or add filler // lines (e.g., when adding lines above w_topline). But it's slow when @@ -634,8 +635,9 @@ static int diff_check_sanity(tabpage_T *tp, diff_T *dp) /// Mark all diff buffers in the current tab page for redraw. /// /// @param dofold Also recompute the folds -static void diff_redraw(int dofold) +void diff_redraw(bool dofold) { + need_diff_redraw = false; FOR_ALL_WINDOWS_IN_TAB(wp, curtab) { if (!wp->w_p_diff) { continue; diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 5ce953e626..b193b4005c 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -771,6 +771,11 @@ void foldUpdate(win_T *wp, linenr_T top, linenr_T bot) return; } + if (need_diff_redraw) { + // will update later + return; + } + // Mark all folds from top to bot as maybe-small. fold_T *fp; (void)foldFind(&wp->w_folds, top, &fp); diff --git a/src/nvim/globals.h b/src/nvim/globals.h index 227119bcee..e9f2800991 100644 --- a/src/nvim/globals.h +++ b/src/nvim/globals.h @@ -744,6 +744,7 @@ EXTERN int maptick INIT(= 0); // tick for each non-mapped char EXTERN int must_redraw INIT(= 0); // type of redraw necessary EXTERN bool skip_redraw INIT(= false); // skip redraw once EXTERN bool do_redraw INIT(= false); // extra redraw once +EXTERN bool need_diff_redraw INIT(= false); // need to call diff_redraw() EXTERN bool must_redraw_pum INIT(= false); // redraw pum. NB: must_redraw // should also be set. diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 1ce0b5217e..7b9601a5a6 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -286,6 +286,11 @@ int update_screen(int type) return FAIL; } + // May have postponed updating diffs. + if (need_diff_redraw) { + diff_redraw(true); + } + if (must_redraw) { if (type < must_redraw) /* use maximal type */ type = must_redraw; |