aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/window.c
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-11-16 16:13:51 -0500
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2019-11-16 16:40:25 -0500
commitb83027858af71e5ca976c3b43e0b798c624f5529 (patch)
treebeae2e17ceb60c68e7f421d6ccdd445063a55566 /src/nvim/window.c
parentda7bb53d995b409208b29a5fd5941075230f1504 (diff)
downloadrneovim-b83027858af71e5ca976c3b43e0b798c624f5529.tar.gz
rneovim-b83027858af71e5ca976c3b43e0b798c624f5529.tar.bz2
rneovim-b83027858af71e5ca976c3b43e0b798c624f5529.zip
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. https://github.com/vim/vim/commit/c8234779790dd873acb88331c50988adf94cc383
Diffstat (limited to 'src/nvim/window.c')
-rw-r--r--src/nvim/window.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 0531ad1938..2a7578e33c 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -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;