closed folds near the EoF not considered
chrisgrieser opened this issue · 2 comments
Thanks for the plugin!
So it seems that calculating the distance of the cursor to the end of the file, this plugin just uses the lne number count. However, when you have a closed fold near the end of the file, this distorts the calculation; even though the viewport is close to the EoF, the line the cursor is on can still be quite far away.
Hi Chris, yeah this is a known issue.
I have tried to resolve it, however I couldn't find a way to get information about the folds.
The opposite happens when turning on line wrapping on a long line, the scrolloff gap gets smaller and smaller.
Do you have any ideas or tips?
Not sure how exactly this plugin does its calculations, but the folding information is straightforward to get via vim.fn.foldclosed
and vim.fn.foldclosedend
:
foldclosedend({lnum})
The result is a Number. If the line {lnum} is in a closed
fold, the result is the number of the last line in that fold.
If the line {lnum} is not in a closed fold, -1 is returned.
https://neovim.io/doc/user/builtin.html#foldclosedend()
So basically, you could check for each line between the cursor line and the last line, whether one of them is closed, and if so, use the result from foldclosedend
to determine the size of the fold.