Mercurial > vim
diff src/window.c @ 18590:41484f342f80 v8.1.2289
patch 8.1.2289: after :diffsplit closing the window does not disable diff
Commit: https://github.com/vim/vim/commit/c8234779790dd873acb88331c50988adf94cc383
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Nov 10 21:00:27 2019 +0100
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.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 10 Nov 2019 21:15:04 +0100 |
parents | 99fc29219b3e |
children | 49b78d6465e5 |
line wrap: on
line diff
--- a/src/window.c +++ b/src/window.c @@ -2438,6 +2438,9 @@ win_close(win_T *win, int free_buf) int help_window = FALSE; tabpage_T *prev_curtab = curtab; frame_T *win_frame = win->w_frame->fr_parent; +#ifdef FEAT_DIFF + int had_diffmode = win->w_p_diff; +#endif if (ERROR_IF_POPUP_WINDOW) return FAIL; @@ -2625,6 +2628,23 @@ win_close(win_T *win, int free_buf) if (help_window) restore_snapshot(SNAP_HELP_IDX, close_curwin); +#ifdef FEAT_DIFF + // 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; + win_T *dwin; + + FOR_ALL_WINDOWS(dwin) + if (dwin->w_p_diff) + ++diffcount; + if (diffcount == 1) + do_cmdline_cmd((char_u *)"diffoff!"); + } +#endif + #if defined(FEAT_GUI) /* When 'guioptions' includes 'L' or 'R' may have to remove scrollbars. */ if (gui.in_use && !win_hasvertsplit())