diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-06-02 08:48:49 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-02 08:48:49 +0800 |
commit | 9f3c4c152664b21593636a59ce21e74ab7000b20 (patch) | |
tree | 7e169b08d198fe6f4b0115c9c130aebdff89af9f /src | |
parent | a0375b68c1803e7453071a20b28249020abe7260 (diff) | |
download | rneovim-9f3c4c152664b21593636a59ce21e74ab7000b20.tar.gz rneovim-9f3c4c152664b21593636a59ce21e74ab7000b20.tar.bz2 rneovim-9f3c4c152664b21593636a59ce21e74ab7000b20.zip |
vim-patch:9.0.1597: cursor ends up below the window after a put (#23873)
Problem: Cursor ends up below the window after a put.
Solution: Mark w_crow and w_botline invalid when changing the cursor line.
(closes vim/vim#12465)
https://github.com/vim/vim/commit/8509014adda188ee8bdf6a2e123fbf15a91b29d2
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/eval.c | 4 | ||||
-rw-r--r-- | src/nvim/move.c | 12 | ||||
-rw-r--r-- | src/nvim/ops.c | 1 |
3 files changed, 12 insertions, 5 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 52924bf9a5..118c1d3012 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -6511,6 +6511,10 @@ pos_T *var2fpos(const typval_T *const tv, const bool dollar_lnum, int *const ret pos.coladd = 0; if (name[0] == 'w' && dollar_lnum) { + // the "w_valid" flags are not reset when moving the cursor, but they + // do matter for update_topline() and validate_botline(). + check_cursor_moved(curwin); + pos.col = 0; if (name[1] == '0') { // "w0": first visible line update_topline(curwin); diff --git a/src/nvim/move.c b/src/nvim/move.c index 9e8abbcd96..48691db26d 100644 --- a/src/nvim/move.c +++ b/src/nvim/move.c @@ -548,18 +548,20 @@ void set_topline(win_T *wp, linenr_T lnum) redraw_later(wp, UPD_VALID); } -// Call this function when the length of the cursor line (in screen -// characters) has changed, and the change is before the cursor. -// Need to take care of w_botline separately! +/// Call this function when the length of the cursor line (in screen +/// characters) has changed, and the change is before the cursor. +/// If the line length changed the number of screen lines might change, +/// requiring updating w_topline. That may also invalidate w_crow. +/// Need to take care of w_botline separately! void changed_cline_bef_curs(void) { - curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL + curwin->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL|VALID_CROW |VALID_CHEIGHT|VALID_TOPLINE); } void changed_cline_bef_curs_win(win_T *wp) { - wp->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL + wp->w_valid &= ~(VALID_WROW|VALID_WCOL|VALID_VIRTCOL|VALID_CROW |VALID_CHEIGHT|VALID_TOPLINE); } diff --git a/src/nvim/ops.c b/src/nvim/ops.c index c39a3273da..2711c3d29c 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -3484,6 +3484,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) if (lnum == curwin->w_cursor.lnum) { // make sure curwin->w_virtcol is updated changed_cline_bef_curs(); + invalidate_botline(); curwin->w_cursor.col += (colnr_T)(totlen - 1); } changed_bytes(lnum, col); |