aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnatolii Sakhnik <sakhnik@gmail.com>2018-12-09 19:44:58 +0200
committerAnatolii Sakhnik <sakhnik@gmail.com>2018-12-09 19:45:56 +0200
commitfe0114ec414108d544da73c3147fd67079f6cc2e (patch)
tree6c58c5e23d0e88dbffe75c5831dd4840edd8779b /src
parent271249a48a4847929410b9055bdb560e52271919 (diff)
downloadrneovim-fe0114ec414108d544da73c3147fd67079f6cc2e.tar.gz
rneovim-fe0114ec414108d544da73c3147fd67079f6cc2e.tar.bz2
rneovim-fe0114ec414108d544da73c3147fd67079f6cc2e.zip
vim-patch:8.1.0402: the DiffUpdate event isn't triggered for :diffput
Problem: The DiffUpdate event isn't triggered for :diffput. Solution: Also trigger DiffUpdate for :diffget and :diffput. https://github.com/vim/vim/commit/198fa066b2ec011e91012c1a3d85a73df7b93f31
Diffstat (limited to 'src')
-rw-r--r--src/nvim/diff.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index 9ac9b6f6db..b9376c311f 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -268,7 +268,7 @@ static void diff_mark_adjust_tp(tabpage_T *tp, int idx, linenr_T line1,
linenr_T line2, long amount, long amount_after)
{
if (diff_internal()) {
- // Will udpate diffs before redrawing. Set _invalid to update the
+ // Will update diffs before redrawing. Set _invalid to update the
// diffs themselves, set _update to also update folds properly just
// before redrawing.
tp->tp_diff_invalid = true;
@@ -886,6 +886,8 @@ void ex_diffupdate(exarg_T *eap)
return;
}
+ int had_diffs = curtab->tp_first_diff != NULL;
+
// Delete all diffblocks.
diff_clear(curtab);
curtab->tp_diff_invalid = false;
@@ -899,7 +901,7 @@ void ex_diffupdate(exarg_T *eap)
}
if (idx_orig == DB_COUNT) {
- return;
+ goto theend;
}
// Only need to do something when there is another buffer.
@@ -911,7 +913,7 @@ void ex_diffupdate(exarg_T *eap)
}
if (idx_new == DB_COUNT) {
- return;
+ goto theend;
}
// Only use the internal method if it did not fail for one of the buffers.
@@ -929,9 +931,13 @@ void ex_diffupdate(exarg_T *eap)
// force updating cursor position on screen
curwin->w_valid_cursor.lnum = 0;
- diff_redraw(true);
-
- apply_autocmds(EVENT_DIFFUPDATED, NULL, NULL, false, curbuf);
+theend:
+ // A redraw is needed if there were diffs and they were cleared, or there
+ // are diffs now, which means they got updated.
+ if (had_diffs || curtab->tp_first_diff != NULL) {
+ diff_redraw(true);
+ apply_autocmds(EVENT_DIFFUPDATED, NULL, NULL, false, curbuf);
+ }
}
///
@@ -2176,7 +2182,8 @@ int diffopt_changed(void)
return FAIL;
}
- // If "icase" or "iwhite" was added or removed, need to update the diff.
+ // If flags were added or removed, or the algorithm was changed, need to
+ // update the diff.
if (diff_flags != diff_flags_new || diff_algorithm != diff_algorithm_new) {
FOR_ALL_TABS(tp) {
tp->tp_diff_invalid = true;
@@ -2734,15 +2741,17 @@ theend:
if (diff_need_update) {
diff_need_update = false;
ex_diffupdate(NULL);
- }
-
- // Check that the cursor is on a valid character and update it's position.
- // When there were filler lines the topline has become invalid.
- check_cursor();
- changed_line_abv_curs();
+ } else {
+ // Check that the cursor is on a valid character and update it's
+ // position. When there were filler lines the topline has become
+ // invalid.
+ check_cursor();
+ changed_line_abv_curs();
- // Also need to redraw the other buffers.
- diff_redraw(false);
+ // Also need to redraw the other buffers.
+ diff_redraw(false);
+ apply_autocmds(EVENT_DIFFUPDATED, NULL, NULL, false, curbuf);
+ }
}
/// Update folds for all diff buffers for entry "dp".