aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/move.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-12-06 06:51:17 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-12-06 07:40:16 +0800
commit11d2704274ff817678e29f115ba1f074a52e519c (patch)
treeffc2b348e0e2f1d0b2a0b97335f5fa4e174488d9 /src/nvim/move.c
parentf3bf1fbf600050fde155e6a1a766b6f848012208 (diff)
downloadrneovim-11d2704274ff817678e29f115ba1f074a52e519c.tar.gz
rneovim-11d2704274ff817678e29f115ba1f074a52e519c.tar.bz2
rneovim-11d2704274ff817678e29f115ba1f074a52e519c.zip
vim-patch:8.2.3193: screenpos() is wrong when 'display' is "lastline"
Problem: screenpos() is wrong when the last line is partially visible and 'display' is "lastline". Solution: Also compute the position for a partially visible line. (closes vim/vim#8599) https://github.com/vim/vim/commit/189663bdac1156237c49925f77bd197c1bdea12c Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/move.c')
-rw-r--r--src/nvim/move.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/nvim/move.c b/src/nvim/move.c
index 1d2a3a2276..05795bf858 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -921,7 +921,7 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp, int *ccolp,
colnr_T coloff = 0;
bool visible_row = false;
- if (pos->lnum >= wp->w_topline && pos->lnum < wp->w_botline) {
+ if (pos->lnum >= wp->w_topline && pos->lnum <= wp->w_botline) {
row = plines_m_win(wp, wp->w_topline, pos->lnum - 1) + 1;
visible_row = true;
} else if (pos->lnum < wp->w_topline) {
@@ -955,15 +955,15 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp, int *ccolp,
col -= wp->w_leftcol;
- if (col >= 0 && col < wp->w_width) {
+ if (col >= 0 && col < wp->w_width && row + rowoff <= wp->w_height) {
coloff = col - scol + (local ? 0 : wp->w_wincol + wp->w_wincol_off) + 1;
} else {
+ // character is left, right or below of the window
scol = ccol = ecol = 0;
- // character is left or right of the window
if (local) {
coloff = col < 0 ? -1 : wp->w_width_inner + 1;
} else {
- row = 0;
+ row = rowoff = 0;
}
}
}