vim-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.
cd38bb4d83
This commit is contained in:
zeertzjq
2022-07-25 20:06:24 +08:00
parent 611b43369e
commit 8543de3a86
2 changed files with 18 additions and 2 deletions

View File

@@ -115,7 +115,10 @@ void diff_buf_delete(buf_T *buf)
tp->tp_diff_invalid = true;
if (tp == curtab) {
diff_redraw(true);
// don't redraw right away, more might change or buffer state
// is invalid right now
need_diff_redraw = true;
redraw_later(curwin, VALID);
}
}
}
@@ -648,7 +651,8 @@ void diff_redraw(bool dofold)
need_diff_redraw = false;
FOR_ALL_WINDOWS_IN_TAB(wp, curtab) {
if (!wp->w_p_diff) {
// when closing windows or wiping buffers skip invalid window
if (!wp->w_p_diff || !buf_valid(wp->w_buffer)) {
continue;
}
redraw_later(wp, SOME_VALID);

View File

@@ -1446,5 +1446,17 @@ func Test_diff_scroll()
call delete('Xright')
endfunc
" This was trying to update diffs for a buffer being closed
func Test_diff_only()
silent! lfile
set diff
lopen
norm o
silent! norm o
set nodiff
%bwipe!
endfunc
" vim: shiftwidth=2 sts=2 expandtab