-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
[RFC] runtime/helptoc: uncache g:helptoc.shell_prompt #16097
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
Conversation
|
Thanks. Did you notice any performance issues? |
I haven't actually tried it myself ;) A reasonable test might be to run a |
|
I think you would need to create a lot of lines for performance to be an issue. This SHELL_PROMPT callback is called once per line to retrieve the property, which I would imagine should be fast. The plugin is doing a regex comparison per line anyway so you would have a linear scaling no matter what and the regex comparison is probably the limiting factor. But we could potentially create a function, e.g. named |
[Assuming I understood what you meant while I'm away from the code] I like this idea of fetching possible changes on demand/as needed while still keeping the cost of the test low (a variable lookup rather than a function call). Doubly so if it provides a good place to hook in the other follow-up. Let me prepare a v2 of this patch. |
Follow up on PR 10446 [1] so that changes at run-time (or after loading a vimrc) are reflected at next use. Instead of "uncaching" the variable by computing SHELL_PROMPT on each use, which could negatively impact performance, reload any user settings before creating the toc. [1]: vim#10446 (comment) Best-viewed-with: --ignore-space-change
Let's say in a terminal buffer we run :HelpToc but it creates a blank
popup because none of our lines match SHELL_PROMPT. We fix that with
:let g:helptoc = #{shell_prompt '…'}
and rerun :HelpToc. The blank popup appears again! If we run a new
command or modify the buffer some other way, :HelpToc starts working.
This is because of the cached popup buffer: it wasn't invalidated by the
change to g:helptoc.
5241774 to
bad2ea9
Compare
|
I've pushed a v2: range-diff: rebase, reload instead of uncache, invalidate cacheI noticed a bit of odd behavior when testing, so I added the tip bad2ea9 (make changes to user settings invalidate the cache, 2024-11-30). It invalidates a little too eagerly at the moment (for example, changing Comments welcome: in particular, I'd like to consider "changing |
|
Hmm my comments on the file didn't seem to show up in the GitHub PR, maybe because it's an individual commit, just pasting below. Is there a reason we need this or any invalidation management code at all? Can't we just have the original code and update SHELL_PROMPT all the time in UpdateUserSettings()? This is just reading a variable from memory and shouldn't really need optimizations around it. (Maybe that's why I think it would actually have been ok if we just call SHELL_PROMPT as a function per line, but either way works). Either way for validation to work you have to query the variable to begin with so you don't save anything. I think to get buffer local we just need something like this: def UpdateUserSettings() #{{{2
SHELL_PROMPT = b:
->get('helptoc', {})
->get('shell_prompt', g:
->get('helptoc', {})
->get('shell_prompt', '^\w\+@\w\+:\f\+\$\s'))
enddef |
I did get a notification about the comments, but if you don't leave them through the commits tab or files changed tab and press "Submit Review" (I think) they won't show up as a "Review."
See above (some formatting lost): I wrote:
and the commit message:
Try it out. For example, my doesn't fix it without this commit, ychin wrote:
This looks right to me, but again I'd rather address that separately (esp. given the cache invalidation bits from refreshing config above). |
|
To be a little more explicit: if you checkout a2a4c86 and do the example case I mentioned, you might be surprised by the results: the initial placement of
Yes, if we don't have a cached toc buffer ;) There might be a way to do things without the check in |
|
Ah you are right. For some reasons I read what you wrote but didn't register. Looks good to me then. |
|
thanks! |
Follow up on PR 10446 1 so that changes at run-time (or after loading a vimrc) are reflected at next use.
As the original comment points out, this may have been done for performance. Please try it out and comment if there are issues.
I'm not sure if the
SHELL_PROMPTdefinition is formatted in a "standard" way under vim9script; feel free to suggest better versions.