Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

closed folds near the EoF not considered #7

Closed
chrisgrieser opened this issue Aug 9, 2023 · 2 comments
Closed

closed folds near the EoF not considered #7

chrisgrieser opened this issue Aug 9, 2023 · 2 comments

Comments

@chrisgrieser
Copy link
Contributor

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.

@Aasim-A
Copy link
Owner

Aasim-A commented Aug 10, 2023

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?

@chrisgrieser
Copy link
Contributor Author

chrisgrieser commented Aug 10, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants