summaryrefslogtreecommitdiffstats
path: root/src/diff.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/diff.c')
-rw-r--r--src/diff.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/diff.c b/src/diff.c
index 80f1eb3368..88e3ec4533 100644
--- a/src/diff.c
+++ b/src/diff.c
@@ -2786,8 +2786,12 @@ ex_diffgetput(exarg_T *eap)
idx_to = idx_other;
// Need to make the other buffer the current buffer to be able to make
// changes in it.
- // set curwin/curbuf to buf and save a few things
+ // Set curwin/curbuf to buf and save a few things.
aucmd_prepbuf(&aco, curtab->tp_diffbuf[idx_other]);
+ if (curbuf != curtab->tp_diffbuf[idx_other])
+ // Could not find a window for this buffer, the rest is likely to
+ // fail.
+ goto theend;
}
// May give the warning for a changed buffer here, which can trigger the