mirror of
https://github.com/vim/vim.git
synced 2025-09-24 03:44:06 -04:00
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.
This commit is contained in:
20
src/diff.c
20
src/diff.c
@@ -292,6 +292,16 @@ diff_mark_adjust_tp(
|
|||||||
linenr_T lnum_deleted = line1; /* lnum of remaining deletion */
|
linenr_T lnum_deleted = line1; /* lnum of remaining deletion */
|
||||||
int check_unchanged;
|
int check_unchanged;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
if (line2 == MAXLNUM)
|
if (line2 == MAXLNUM)
|
||||||
{
|
{
|
||||||
/* mark_adjust(99, MAXLNUM, 9, 0): insert lines */
|
/* mark_adjust(99, MAXLNUM, 9, 0): insert lines */
|
||||||
@@ -640,7 +650,7 @@ diff_check_sanity(tabpage_T *tp, diff_T *dp)
|
|||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
diff_redraw(
|
diff_redraw(
|
||||||
int dofold) /* also recompute the folds */
|
int dofold) // also recompute the folds
|
||||||
{
|
{
|
||||||
win_T *wp;
|
win_T *wp;
|
||||||
int n;
|
int n;
|
||||||
@@ -863,7 +873,7 @@ theend:
|
|||||||
* Note that if the internal diff failed for one of the buffers, the external
|
* Note that if the internal diff failed for one of the buffers, the external
|
||||||
* diff will be used anyway.
|
* diff will be used anyway.
|
||||||
*/
|
*/
|
||||||
static int
|
int
|
||||||
diff_internal(void)
|
diff_internal(void)
|
||||||
{
|
{
|
||||||
return (diff_flags & DIFF_INTERNAL) != 0 && *p_dex == NUL;
|
return (diff_flags & DIFF_INTERNAL) != 0 && *p_dex == NUL;
|
||||||
@@ -887,9 +897,9 @@ diff_internal_failed(void)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Completely update the diffs for the buffers involved.
|
* Completely update the diffs for the buffers involved.
|
||||||
* This uses the ordinary "diff" command.
|
* When using the external "diff" command the buffers are written to a file,
|
||||||
* The buffers are written to a file, also for unmodified buffers (the file
|
* also for unmodified buffers (the file could have been produced by
|
||||||
* could have been produced by autocommands, e.g. the netrw plugin).
|
* autocommands, e.g. the netrw plugin).
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ex_diffupdate(exarg_T *eap) // "eap" can be NULL
|
ex_diffupdate(exarg_T *eap) // "eap" can be NULL
|
||||||
|
@@ -1200,6 +1200,15 @@ main_loop(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if defined(FEAT_DIFF)
|
#if defined(FEAT_DIFF)
|
||||||
|
// 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
|
/* Scroll-binding for diff mode may have been postponed until
|
||||||
* here. Avoids doing it for every change. */
|
* here. Avoids doing it for every change. */
|
||||||
if (diff_need_scrollbind)
|
if (diff_need_scrollbind)
|
||||||
|
@@ -3093,7 +3093,7 @@ changed_lines(
|
|||||||
changed_lines_buf(curbuf, lnum, lnume, xtra);
|
changed_lines_buf(curbuf, lnum, lnume, xtra);
|
||||||
|
|
||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
if (xtra == 0 && curwin->w_p_diff)
|
if (xtra == 0 && curwin->w_p_diff && !diff_internal())
|
||||||
{
|
{
|
||||||
/* When the number of lines doesn't change then mark_adjust() isn't
|
/* When the number of lines doesn't change then mark_adjust() isn't
|
||||||
* called and other diff buffers still need to be marked for
|
* called and other diff buffers still need to be marked for
|
||||||
@@ -3173,6 +3173,11 @@ changed_common(
|
|||||||
/* mark the buffer as modified */
|
/* mark the buffer as modified */
|
||||||
changed();
|
changed();
|
||||||
|
|
||||||
|
#ifdef FEAT_DIFF
|
||||||
|
if (curwin->w_p_diff && diff_internal())
|
||||||
|
curtab->tp_diff_update = TRUE;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* set the '. mark */
|
/* set the '. mark */
|
||||||
if (!cmdmod.keepjumps)
|
if (!cmdmod.keepjumps)
|
||||||
{
|
{
|
||||||
|
@@ -4,6 +4,7 @@ void diff_buf_adjust(win_T *win);
|
|||||||
void diff_buf_add(buf_T *buf);
|
void diff_buf_add(buf_T *buf);
|
||||||
void diff_invalidate(buf_T *buf);
|
void diff_invalidate(buf_T *buf);
|
||||||
void diff_mark_adjust(linenr_T line1, linenr_T line2, long amount, long amount_after);
|
void diff_mark_adjust(linenr_T line1, linenr_T line2, long amount, long amount_after);
|
||||||
|
int diff_internal(void);
|
||||||
void ex_diffupdate(exarg_T *eap);
|
void ex_diffupdate(exarg_T *eap);
|
||||||
void ex_diffpatch(exarg_T *eap);
|
void ex_diffpatch(exarg_T *eap);
|
||||||
void ex_diffsplit(exarg_T *eap);
|
void ex_diffsplit(exarg_T *eap);
|
||||||
|
@@ -2509,7 +2509,8 @@ struct tabpage_S
|
|||||||
#ifdef FEAT_DIFF
|
#ifdef FEAT_DIFF
|
||||||
diff_T *tp_first_diff;
|
diff_T *tp_first_diff;
|
||||||
buf_T *(tp_diffbuf[DB_COUNT]);
|
buf_T *(tp_diffbuf[DB_COUNT]);
|
||||||
int tp_diff_invalid; /* list of diffs is outdated */
|
int tp_diff_invalid; // list of diffs is outdated
|
||||||
|
int tp_diff_update; // update diffs before redrawing
|
||||||
#endif
|
#endif
|
||||||
frame_T *(tp_snapshot[SNAP_COUNT]); /* window layout snapshots */
|
frame_T *(tp_snapshot[SNAP_COUNT]); /* window layout snapshots */
|
||||||
#ifdef FEAT_EVAL
|
#ifdef FEAT_EVAL
|
||||||
|
@@ -794,6 +794,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
394,
|
||||||
/**/
|
/**/
|
||||||
393,
|
393,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user