[RFC] runtime/helptoc: uncache g:helptoc.shell_prompt by benknoble · Pull Request #16097 · vim/vim

@benknoble mentioned this pull request

Nov 21, 2024
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.