aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/window.c
diff options
context:
space:
mode:
authorglepnir <glephunter@gmail.com>2024-04-20 12:01:28 +0800
committerglepnir <glephunter@gmail.com>2024-04-21 15:25:46 +0800
commit5f18dd30137565da782c155b52b530c172b3b29d (patch)
treee4b6f641be8cdee56c694f1845c0e45c02a3e353 /src/nvim/window.c
parent4d52b0cf670502caf81b70f2f1e6f8c548b78f58 (diff)
downloadrneovim-5f18dd30137565da782c155b52b530c172b3b29d.tar.gz
rneovim-5f18dd30137565da782c155b52b530c172b3b29d.tar.bz2
rneovim-5f18dd30137565da782c155b52b530c172b3b29d.zip
fix(float): wrong position when bufpos is set
Problem: when lnum in bufpos is out of range the position of float is wired. Solution: avoid the height value out of buffer line range.
Diffstat (limited to 'src/nvim/window.c')
-rw-r--r--src/nvim/window.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/nvim/window.c b/src/nvim/window.c
index ea879d450b..8c63090419 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -827,7 +827,8 @@ void ui_ext_win_position(win_T *wp, bool validate)
row += row_off;
col += col_off;
if (c.bufpos.lnum >= 0) {
- pos_T pos = { c.bufpos.lnum + 1, c.bufpos.col, 0 };
+ int lnum = MIN(c.bufpos.lnum + 1, win->w_buffer->b_ml.ml_line_count);
+ pos_T pos = { lnum, c.bufpos.col, 0 };
int trow, tcol, tcolc, tcole;
textpos2screenpos(win, &pos, &trow, &tcol, &tcolc, &tcole, true);
row += trow - 1;