commit f54bc6c7d645ff18825cf323885147162524110f
parent 2cdff6c32ca80f623cd39f79cf6bbe1281dc58a3
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 22 Apr 2021 11:51:07 +0200
indicator: adjust the size to the number of visible lines, not chunks
Since two commits ago, the position of the indicator shows the position
of the viewport relative to the full buffer in terms of actual lines,
not of visual chunks (to avoid excessive computation). But the size of
the indicator stayed constant, as if it always covered as many lines as
the edit window has rows. But the latter will not be the case when
softwrapping occurs. Therefore, when softwrapping, compute how many
actual lines are visible in the viewport, and adjust the size of the
indicator accordingly.
Diffstat:
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/winio.c b/src/winio.c
@@ -3057,8 +3057,22 @@ void draw_scrollbar(void)
{
int totallines = openfile->filebot->lineno;
int fromline = openfile->edittop->lineno - 1;
+ int coveredlines = editwinrows;
+
+ if (ISSET(SOFTWRAP)) {
+ linestruct *line = openfile->edittop;
+ int extras = extra_chunks_in(line) - chunk_for(openfile->firstcolumn, line);
+
+ while (line->lineno + extras < fromline + editwinrows && line->next) {
+ line = line->next;
+ extras += extra_chunks_in(line);
+ }
+
+ coveredlines = line->lineno - fromline;
+ }
+
int lowest = (fromline * editwinrows) / totallines;
- int highest = lowest + (editwinrows * editwinrows) / totallines;
+ int highest = lowest + (editwinrows * coveredlines) / totallines;
if (editwinrows > totallines)
highest = editwinrows;