aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/move.c16
-rw-r--r--src/nvim/plines.c15
2 files changed, 15 insertions, 16 deletions
diff --git a/src/nvim/move.c b/src/nvim/move.c
index 48691db26d..6fb6656472 100644
--- a/src/nvim/move.c
+++ b/src/nvim/move.c
@@ -1069,21 +1069,20 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp, int *ccolp,
bool visible_row = false;
bool is_folded = false;
- if (pos->lnum >= wp->w_topline && pos->lnum <= wp->w_botline) {
- linenr_T lnum = pos->lnum;
+ linenr_T lnum = pos->lnum;
+ if (lnum >= wp->w_topline && lnum <= wp->w_botline) {
is_folded = hasFoldingWin(wp, lnum, &lnum, NULL, true, NULL);
row = plines_m_win(wp, wp->w_topline, lnum - 1) + 1;
// Add filler lines above this buffer line.
- row += win_get_fill(wp, lnum);
+ row += lnum == wp->w_topline ? wp->w_topfill : win_get_fill(wp, lnum);
visible_row = true;
- } else if (!local || pos->lnum < wp->w_topline) {
+ } else if (!local || lnum < wp->w_topline) {
row = 0;
} else {
row = wp->w_height_inner;
}
- bool existing_row = (pos->lnum > 0
- && pos->lnum <= wp->w_buffer->b_ml.ml_line_count);
+ bool existing_row = (lnum > 0 && lnum <= wp->w_buffer->b_ml.ml_line_count);
if ((local || visible_row) && existing_row) {
const colnr_T off = win_col_off(wp);
@@ -1091,6 +1090,7 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp, int *ccolp,
row += local ? 0 : wp->w_winrow + wp->w_winrow_off;
coloff = (local ? 0 : wp->w_wincol + wp->w_wincol_off) + 1 + off;
} else {
+ assert(lnum == pos->lnum);
getvcol(wp, pos, &scol, &ccol, &ecol);
// similar to what is done in validate_cursor_col()
@@ -1098,6 +1098,10 @@ void textpos2screenpos(win_T *wp, pos_T *pos, int *rowp, int *scolp, int *ccolp,
col += off;
int width = wp->w_width_inner - off + win_col_off2(wp);
+ if (lnum == wp->w_topline) {
+ col -= wp->w_skipcol;
+ }
+
// long line wrapping, adjust row
if (wp->w_p_wrap && col >= (colnr_T)wp->w_width_inner && width > 0) {
// use same formula as what is used in curs_columns()
diff --git a/src/nvim/plines.c b/src/nvim/plines.c
index 25c745ae97..5f28715f53 100644
--- a/src/nvim/plines.c
+++ b/src/nvim/plines.c
@@ -38,8 +38,7 @@
/// @param winheight when true limit to window height
int plines_win(win_T *wp, linenr_T lnum, bool winheight)
{
- // Check for filler lines above this buffer line. When folded the result
- // is one line anyway.
+ // Check for filler lines above this buffer line.
return plines_win_nofill(wp, lnum, winheight) + win_get_fill(wp, lnum);
}
@@ -199,16 +198,12 @@ int plines_win_col(win_T *wp, linenr_T lnum, long column)
int plines_win_full(win_T *wp, linenr_T lnum, linenr_T *const nextp, bool *const foldedp,
const bool cache, const bool winheight)
{
- bool folded = hasFoldingWin(wp, lnum, NULL, nextp, cache, NULL);
- if (foldedp) {
+ bool folded = hasFoldingWin(wp, lnum, &lnum, nextp, cache, NULL);
+ if (foldedp != NULL) {
*foldedp = folded;
}
- if (folded) {
- return 1;
- } else if (lnum == wp->w_topline) {
- return plines_win_nofill(wp, lnum, winheight) + wp->w_topfill;
- }
- return plines_win(wp, lnum, winheight);
+ return ((folded ? 1 : plines_win_nofill(wp, lnum, winheight)) +
+ (lnum == wp->w_topline ? wp->w_topfill : win_get_fill(wp, lnum)));
}
int plines_m_win(win_T *wp, linenr_T first, linenr_T last)