aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnatolii Sakhnik <sakhnik@gmail.com>2018-12-09 15:31:22 +0200
committerAnatolii Sakhnik <sakhnik@gmail.com>2018-12-09 19:45:56 +0200
commit7b6c92eac1b7aa702f734120bdd18b5a4f6cfe04 (patch)
tree772c85f99dfe923ffb0358ecad3b62613c081393 /src
parent972ad1119557a0f72f1907c6758d6ed56438e5b3 (diff)
downloadrneovim-7b6c92eac1b7aa702f734120bdd18b5a4f6cfe04.tar.gz
rneovim-7b6c92eac1b7aa702f734120bdd18b5a4f6cfe04.tar.bz2
rneovim-7b6c92eac1b7aa702f734120bdd18b5a4f6cfe04.zip
vim-patch:8.1.0394: diffs are not always updated correctly
Problem: Diffs are not always updated correctly. Solution: When using internal diff update for any changes properly. https://github.com/vim/vim/commit/e3521d9cbb786806eaff106707851d37d2c0ecef
Diffstat (limited to 'src')
-rw-r--r--src/nvim/buffer_defs.h1
-rw-r--r--src/nvim/diff.c17
-rw-r--r--src/nvim/misc1.c12
-rw-r--r--src/nvim/normal.c8
4 files changed, 30 insertions, 8 deletions
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index 238893260e..e8975f0622 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -842,6 +842,7 @@ struct tabpage_S {
diff_T *tp_first_diff;
buf_T *(tp_diffbuf[DB_COUNT]);
int tp_diff_invalid; ///< list of diffs is outdated
+ int tp_diff_update; ///< update diffs before redrawing
frame_T *(tp_snapshot[SNAP_COUNT]); ///< window layout snapshots
ScopeDictDictItem tp_winvar; ///< Variable for "t:" Dictionary.
dict_T *tp_vars; ///< Internal variables, local to tab page.
diff --git a/src/nvim/diff.c b/src/nvim/diff.c
index 6e034485d9..a927983374 100644
--- a/src/nvim/diff.c
+++ b/src/nvim/diff.c
@@ -266,6 +266,15 @@ void diff_mark_adjust(linenr_T line1, linenr_T line2, long amount,
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
+ // diffs themselves, set _update to also update folds properly just
+ // before redrawing.
+ tp->tp_diff_invalid = true;
+ tp->tp_diff_update = true;
+ return;
+ }
+
int inserted;
int deleted;
if (line2 == MAXLNUM) {
@@ -840,7 +849,7 @@ theend:
/// Note that if the internal diff failed for one of the buffers, the external
/// diff will be used anyway.
///
-static int diff_internal(void)
+int diff_internal(void)
{
return (diff_flags & DIFF_INTERNAL) != 0 && *p_dex == NUL;
}
@@ -864,9 +873,9 @@ static int diff_internal_failed(void)
/// Completely update the diffs for the buffers involved.
///
-/// This uses the ordinary "diff" command.
-/// The buffers are written to a file, also for unmodified buffers (the file
-/// could have been produced by autocommands, e.g. the netrw plugin).
+/// When using the external "diff" command the buffers are written to a file,
+/// also for unmodified buffers (the file could have been produced by
+/// autocommands, e.g. the netrw plugin).
///
/// @param eap can be NULL
void ex_diffupdate(exarg_T *eap)
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c
index d4a406cdba..d77c196a3a 100644
--- a/src/nvim/misc1.c
+++ b/src/nvim/misc1.c
@@ -1953,10 +1953,10 @@ changed_lines(
{
changed_lines_buf(curbuf, lnum, lnume, xtra);
- if (xtra == 0 && curwin->w_p_diff) {
- /* When the number of lines doesn't change then mark_adjust() isn't
- * called and other diff buffers still need to be marked for
- * displaying. */
+ if (xtra == 0 && curwin->w_p_diff && !diff_internal()) {
+ // When the number of lines doesn't change then mark_adjust() isn't
+ // called and other diff buffers still need to be marked for
+ // displaying.
linenr_T wlnum;
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
@@ -2025,6 +2025,10 @@ static void changed_common(linenr_T lnum, colnr_T col, linenr_T lnume, long xtra
/* mark the buffer as modified */
changed();
+ if (curwin->w_p_diff && diff_internal()) {
+ curtab->tp_diff_update = true;
+ }
+
/* set the '. mark */
if (!cmdmod.keepjumps) {
RESET_FMARK(&curbuf->b_last_change, ((pos_T) {lnum, col, 0}), 0);
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index f87de52a82..38ee0936aa 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -1325,6 +1325,14 @@ static int normal_check(VimState *state)
normal_check_cursor_moved(s);
normal_check_text_changed(s);
+ // Updating diffs from changed() does not always work properly,
+ // esp. updating folds. Do an update just before redrawing if
+ // needed.
+ if (curtab->tp_diff_update || curtab->tp_diff_invalid) {
+ ex_diffupdate(NULL);
+ curtab->tp_diff_update = false;
+ }
+
// Scroll-binding for diff mode may have been postponed until
// here. Avoids doing it for every change.
if (diff_need_scrollbind) {