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.master
parent
2cdff6c32c
commit
f54bc6c7d6
16
src/winio.c
16
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;
|
||||
|
|
Loading…
Reference in New Issue