vim-patch:8.1.2289: after :diffsplit closing the window does not disable diff

Problem:    After :diffsplit closing the window does not disable diff.
Solution:   Add "closeoff" to 'diffopt' and add it to the default.
c823477979
This commit is contained in:
Jan Edmund Lazo
2019-11-16 16:13:51 -05:00
parent da7bb53d99
commit b83027858a
5 changed files with 71 additions and 4 deletions

View File

@@ -2418,6 +2418,7 @@ int win_close(win_T *win, bool free_buf)
bool help_window = false;
tabpage_T *prev_curtab = curtab;
frame_T *win_frame = win->w_floating ? NULL : win->w_frame->fr_parent;
const bool had_diffmode = win->w_p_diff;
if (last_window() && !win->w_floating) {
EMSG(_("E444: Cannot close last window"));
@@ -2642,6 +2643,22 @@ int win_close(win_T *win, bool free_buf)
if (help_window)
restore_snapshot(SNAP_HELP_IDX, close_curwin);
// If the window had 'diff' set and now there is only one window left in
// the tab page with 'diff' set, and "closeoff" is in 'diffopt', then
// execute ":diffoff!".
if (diffopt_closeoff() && had_diffmode && curtab == prev_curtab) {
int diffcount = 0;
FOR_ALL_WINDOWS_IN_TAB(dwin, curtab) {
if (dwin->w_p_diff) {
diffcount++;
}
}
if (diffcount == 1) {
do_cmdline_cmd("diffoff!");
}
}
curwin->w_pos_changed = true;
redraw_all_later(NOT_VALID);
return OK;