diff options
author | Marco Hinz <mh.codebro@gmail.com> | 2019-03-27 18:02:56 +0100 |
---|---|---|
committer | Marco Hinz <mh.codebro@gmail.com> | 2019-05-06 16:31:58 +0200 |
commit | b0e3b5cf2e1237aa9071f8ff73899877f1c0d56d (patch) | |
tree | 2fbfd72a28c7533f4cd591d1ef00f9e25180beae /src/nvim/fileio.c | |
parent | 4658e9c1d9ba52edcdaec1ba5d6075b6bcef6771 (diff) | |
download | rneovim-b0e3b5cf2e1237aa9071f8ff73899877f1c0d56d.tar.gz rneovim-b0e3b5cf2e1237aa9071f8ff73899877f1c0d56d.tar.bz2 rneovim-b0e3b5cf2e1237aa9071f8ff73899877f1c0d56d.zip |
aucmd_win: use a floating window
Diffstat (limited to 'src/nvim/fileio.c')
-rw-r--r-- | src/nvim/fileio.c | 47 |
1 files changed, 15 insertions, 32 deletions
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c index 77ddbb1eda..433c571108 100644 --- a/src/nvim/fileio.c +++ b/src/nvim/fileio.c @@ -6520,21 +6520,14 @@ bool check_nomodeline(char_u **argp) return true; } -/* - * Prepare for executing autocommands for (hidden) buffer "buf". - * Search for a visible window containing the current buffer. If there isn't - * one then use "aucmd_win". - * Set "curbuf" and "curwin" to match "buf". - */ -void -aucmd_prepbuf ( - aco_save_T *aco, /* structure to save values in */ - buf_T *buf /* new curbuf */ -) +/// Prepare for executing autocommands for (hidden) buffer "buf". +/// Search for a visible window containing the current buffer. If there isn't +/// one then use "aucmd_win". +/// Set "curbuf" and "curwin" to match "buf". +void aucmd_prepbuf(aco_save_T *aco, buf_T *buf) { - win_T *win; - int save_ea; - int save_acd; + win_T *win; + bool auwin_appended = false; /* Find a window that is for the new buffer */ if (buf == curbuf) { /* be quick when buf is curbuf */ @@ -6552,6 +6545,7 @@ aucmd_prepbuf ( /* Allocate "aucmd_win" when needed. */ if (win == NULL && aucmd_win == NULL) { win_alloc_aucmd_win(); + auwin_appended = true; } if (win == NULL && aucmd_win_used) /* Strange recursive autocommand, fall back to using the current @@ -6586,23 +6580,18 @@ aucmd_prepbuf ( aco->globaldir = globaldir; globaldir = NULL; - - /* Split the current window, put the aucmd_win in the upper half. - * We don't want the BufEnter or WinEnter autocommands. */ block_autocmds(); - make_snapshot(SNAP_AUCMD_IDX); - save_ea = p_ea; - p_ea = false; + if (!auwin_appended) { + win_append(lastwin, aucmd_win); + } - /* Prevent chdir() call in win_enter_ext(), through do_autochdir(). */ - save_acd = p_acd; + // Prevent chdir() call in win_enter_ext(), through do_autochdir() + int save_acd = p_acd; p_acd = false; - - (void)win_split_ins(0, WSP_TOP, aucmd_win, 0); - (void)win_comp_pos(); /* recompute window positions */ - p_ea = save_ea; + win_enter(aucmd_win, false); p_acd = save_acd; unblock_autocmds(); + curwin = aucmd_win; } curbuf = buf; @@ -6616,8 +6605,6 @@ aucmd_prepbuf ( /// @param aco structure holding saved values void aucmd_restbuf(aco_save_T *aco) { - int dummy; - if (aco->use_aucmd_win) { curbuf->b_nwindows--; // Find "aucmd_win", it can't be closed, but it may be in another tab page. @@ -6636,8 +6623,6 @@ void aucmd_restbuf(aco_save_T *aco) } win_found: - // Remove the window and frame from the tree of frames. - (void)winframe_remove(curwin, &dummy, NULL); win_remove(curwin, NULL); aucmd_win_used = false; last_status(false); // may need to remove last status line @@ -6647,8 +6632,6 @@ win_found: close_tabpage(curtab); } - restore_snapshot(SNAP_AUCMD_IDX, false); - (void)win_comp_pos(); // recompute window positions unblock_autocmds(); if (win_valid(aco->save_curwin)) { |