diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2019-05-08 18:01:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-08 18:01:21 +0200 |
commit | 8330cc22afec67d9dbc2ad8b4a39eaf62fdf16d1 (patch) | |
tree | e22baa51856201ff97e2167a82a37a625ab6d20d /src/nvim/buffer_defs.h | |
parent | d36ef9339f398988d4ccefd4780b2f289b0c7f83 (diff) | |
download | rneovim-8330cc22afec67d9dbc2ad8b4a39eaf62fdf16d1.tar.gz rneovim-8330cc22afec67d9dbc2ad8b4a39eaf62fdf16d1.tar.bz2 rneovim-8330cc22afec67d9dbc2ad8b4a39eaf62fdf16d1.zip |
vim-patch:8.1.1205: BufReadPre may move the cursor #9980
Problem: A BufReadPre autocommand may cause the cursor to move.
Solution: Restore the cursor position after executing the autocommand,
unless the autocommand moved it. (Christian Brabandt,
closes vim/vim#4302, closes vim/vim#4294)
https://github.com/vim/vim/commit/a68e59590905da9b4448ff1fcac929ad1a18da9e
Diffstat (limited to 'src/nvim/buffer_defs.h')
-rw-r--r-- | src/nvim/buffer_defs.h | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index 6d99a06eb9..5e28a7b513 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -999,6 +999,16 @@ typedef struct { .relative = 0, .external = false, \ .focusable = true }) +// Structure to store last cursor position and topline. Used by check_lnums() +// and reset_lnums(). +typedef struct +{ + int w_topline_save; // original topline value + int w_topline_corr; // corrected topline value + pos_T w_cursor_save; // original cursor position + pos_T w_cursor_corr; // corrected cursor position +} pos_save_T; + /// Structure which contains all information that belongs to a window. /// /// All row numbers are relative to the start of the window, except w_winrow. @@ -1091,17 +1101,18 @@ struct window_S { colnr_T w_skipcol; /* starting column when a single line doesn't fit in the window */ - /* - * Layout of the window in the screen. - * May need to add "msg_scrolled" to "w_winrow" in rare situations. - */ - int w_winrow; /* first row of window in screen */ - int w_height; /* number of rows in window, excluding - status/command line(s) */ - int w_status_height; /* number of status lines (0 or 1) */ - int w_wincol; /* Leftmost column of window in screen. */ - int w_width; /* Width of window, excluding separation. */ - int w_vsep_width; /* Number of separator columns (0 or 1). */ + // + // Layout of the window in the screen. + // May need to add "msg_scrolled" to "w_winrow" in rare situations. + // + int w_winrow; // first row of window in screen + int w_height; // number of rows in window, excluding + // status/command line(s) + int w_status_height; // number of status lines (0 or 1) + int w_wincol; // Leftmost column of window in screen. + int w_width; // Width of window, excluding separation. + int w_vsep_width; // Number of separator columns (0 or 1). + pos_save_T w_save_cursor; // backup of cursor pos and topline // inner size of window, which can be overridden by external UI int w_height_inner; |