mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 09:26:30 +00:00
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:
@@ -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;
|
||||
|
Reference in New Issue
Block a user