Skip to content

Commit cd38bb4

Browse files
committed
patch 8.2.5163: crash when deleting buffers in diff mode
Problem: Crash when deleting buffers in diff mode. Solution: Recompute diffs later. Skip window without a valid buffer.
1 parent 0971c7a commit cd38bb4

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

Diff for: src/diff.c

+8-2
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,12 @@ diff_buf_delete(buf_T *buf)
119119
tp->tp_diffbuf[i] = NULL;
120120
tp->tp_diff_invalid = TRUE;
121121
if (tp == curtab)
122-
diff_redraw(TRUE);
122+
{
123+
// don't redraw right away, more might change or buffer state
124+
// is invalid right now
125+
need_diff_redraw = TRUE;
126+
redraw_later(VALID);
127+
}
123128
}
124129
}
125130
}
@@ -670,7 +675,8 @@ diff_redraw(
670675

671676
need_diff_redraw = FALSE;
672677
FOR_ALL_WINDOWS(wp)
673-
if (wp->w_p_diff)
678+
// when closing windows or wiping buffers skip invalid window
679+
if (wp->w_p_diff && buf_valid(wp->w_buffer))
674680
{
675681
redraw_win_later(wp, SOME_VALID);
676682
if (wp != curwin)

Diff for: src/testdir/test_diffmode.vim

+12
Original file line numberDiff line numberDiff line change
@@ -1603,5 +1603,17 @@ func Test_diff_scroll()
16031603
call delete('Xright')
16041604
endfunc
16051605

1606+
" This was trying to update diffs for a buffer being closed
1607+
func Test_diff_only()
1608+
silent! lfile
1609+
set diff
1610+
lopen
1611+
norm o
1612+
silent! norm o
1613+
1614+
set nodiff
1615+
%bwipe!
1616+
endfunc
1617+
16061618

16071619
" vim: shiftwidth=2 sts=2 expandtab

Diff for: src/version.c

+2
Original file line numberDiff line numberDiff line change
@@ -735,6 +735,8 @@ static char *(features[]) =
735735

736736
static int included_patches[] =
737737
{ /* Add new patch number below this line */
738+
/**/
739+
5163,
738740
/**/
739741
5162,
740742
/**/

0 commit comments

Comments
 (0)