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

cache fold levels #3049

Closed
Konfekt opened this issue Dec 3, 2024 · 5 comments
Closed

cache fold levels #3049

Konfekt opened this issue Dec 3, 2024 · 5 comments

Comments

@Konfekt
Copy link
Contributor

Konfekt commented Dec 3, 2024

To follow up on #2427 (comment) :

Yes, it will once, but then it just spits out the precomputed fold level for each line till the next change.
Whereas I am under the impression that as Vim implements &foldmethod=expr the function is called for every line and then each such has to redo the computation.
In contrast, this recomputation is only done once, how knows for which line (likely the first), and then stored and retrieved in all subsequent function calls (for higher line numbers).

This might be too apparent an idea, but somehow I never see this caching

@Konfekt
Copy link
Contributor Author

Konfekt commented Dec 3, 2024

I suppose the initial idea of &foldexpr was something like computing indent levels for each line individually, not the more intricate computations of syntax tree depths

@lervag
Copy link
Owner

lervag commented Dec 3, 2024

Oh, yes, I think you are right. This is definitely something to consider! I'm a little behind on following up issues lately, so I'll likely not put this at top priority right now, but I'll get around to it unless you (or someone else) beats me to it. 😊

@Konfekt
Copy link
Contributor Author

Konfekt commented Dec 3, 2024

Thank you then for the kind consideration ;) This was just for inspiration rather than imposing deadlines; it might be as simple a change as adding the changedtick check around here

let l:value = l:type.level(l:line, a:lnum)

@lervag
Copy link
Owner

lervag commented Dec 3, 2024

Yes, I think you are right that this may be quite simple. :)

@lervag
Copy link
Owner

lervag commented Dec 11, 2024

I've pushed a branch and opened a PR, see #3054. Let's continue the discussion there.

@lervag lervag closed this as completed Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants