aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/buffer_defs.h28
-rw-r--r--src/nvim/fileio.c5
-rw-r--r--src/nvim/fileio.h1
3 files changed, 19 insertions, 15 deletions
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h
index 48cef9b1e7..d35e3b49d8 100644
--- a/src/nvim/buffer_defs.h
+++ b/src/nvim/buffer_defs.h
@@ -987,18 +987,16 @@ typedef struct {
.relative = 0, .external = false, \
.focusable = true })
-/*
- * Structure which contains all information that belongs to a window
- *
- * All row numbers are relative to the start of the window, except w_winrow.
- */
+/// Structure which contains all information that belongs to a window.
+///
+/// All row numbers are relative to the start of the window, except w_winrow.
struct window_S {
handle_T handle; ///< unique identifier for the window
buf_T *w_buffer; ///< buffer we are a window into (used
///< often, keep it the first item!)
- synblock_T *w_s; /* for :ownsyntax */
+ synblock_T *w_s; ///< for :ownsyntax
int w_hl_id_normal; ///< 'winhighlight' normal id
int w_hl_attr_normal; ///< 'winhighlight' normal final attrs
@@ -1008,18 +1006,18 @@ struct window_S {
int w_hl_needs_update; ///< attrs need to be recalculated
- win_T *w_prev; /* link to previous window */
- win_T *w_next; /* link to next window */
- bool w_closing; /* window is being closed, don't let
- autocommands close it too. */
+ win_T *w_prev; ///< link to previous window
+ win_T *w_next; ///< link to next window
+ bool w_closing; ///< window is being closed, don't let
+ /// autocommands close it too.
- frame_T *w_frame; /* frame containing this window */
+ frame_T *w_frame; ///< frame containing this window
- pos_T w_cursor; /* cursor position in buffer */
+ pos_T w_cursor; ///< cursor position in buffer
- colnr_T w_curswant; /* The column we'd like to be at. This is
- used to try to stay in the same column
- for up/down cursor motions. */
+ colnr_T w_curswant; ///< Column we want to be at. This is
+ /// used to try to stay in the same column
+ /// for up/down cursor motions.
int w_set_curswant; // If set, then update w_curswant the next
// time through cursupdate() to the
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index 7be4107c94..53b945d983 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -6527,6 +6527,7 @@ aucmd_prepbuf (
win = curwin;
aco->save_curwin = curwin;
+ aco->save_prevwin = prevwin;
aco->save_curbuf = curbuf;
if (win != NULL) {
/* There is a window for "buf" in the current tab page, make it the
@@ -6624,6 +6625,8 @@ win_found:
// Hmm, original window disappeared. Just use the first one.
curwin = firstwin;
}
+ prevwin = win_valid(aco->save_prevwin) ? aco->save_prevwin
+ : firstwin; // window disappeared?
vars_clear(&aucmd_win->w_vars->dv_hashtab); // free all w: variables
hash_init(&aucmd_win->w_vars->dv_hashtab); // re-use the hashtab
curbuf = curwin->w_buffer;
@@ -6656,6 +6659,8 @@ win_found:
}
curwin = aco->save_curwin;
+ prevwin = win_valid(aco->save_prevwin) ? aco->save_prevwin
+ : firstwin; // window disappeared?
curbuf = curwin->w_buffer;
// In case the autocommand moves the cursor to a position that does not
// exist in curbuf
diff --git a/src/nvim/fileio.h b/src/nvim/fileio.h
index 8db4b89806..a6011ec414 100644
--- a/src/nvim/fileio.h
+++ b/src/nvim/fileio.h
@@ -23,6 +23,7 @@ typedef struct {
buf_T *save_curbuf; ///< saved curbuf
int use_aucmd_win; ///< using aucmd_win
win_T *save_curwin; ///< saved curwin
+ win_T *save_prevwin; ///< saved prevwin
win_T *new_curwin; ///< new curwin
bufref_T new_curbuf; ///< new curbuf
char_u *globaldir; ///< saved value of globaldir