runtime(helptoc): reload cached g:helptoc.shell_prompt when starting toc Commit: https://github.com/vim/vim/commit/c74a87eea2cffe911dc5741ca29199165bea631e Author: D. Ben Knoble <ben.knoble+git...@gmail.com> Date: Sun Dec 1 16:06:18 2024 +0100
runtime(helptoc): reload cached g:helptoc.shell_prompt when starting toc 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. Also make sure, changes to the shell prompt variable do correctly invalidate b:toc, so that the table of content is correctly re-created after user makes any changes. [1]: https://github.com/vim/vim/pull/10446#issuecomment-2485169333 closes: #16097 Signed-off-by: D. Ben Knoble <ben.knoble+git...@gmail.com> Signed-off-by: Christian Brabandt <c...@256bit.org> diff --git a/runtime/pack/dist/opt/helptoc/autoload/helptoc.vim b/runtime/pack/dist/opt/helptoc/autoload/helptoc.vim index 087da798e..c0d86a4e6 100644 --- a/runtime/pack/dist/opt/helptoc/autoload/helptoc.vim +++ b/runtime/pack/dist/opt/helptoc/autoload/helptoc.vim @@ -2,9 +2,20 @@ vim9script noclear # Config {{{1 -const SHELL_PROMPT: string = g: - ->get('helptoc', {}) - ->get('shell_prompt', '^\w\+@\w\+:\+\$\s') +var SHELL_PROMPT: string = '' + +def UpdateUserSettings() #{{{2 + var new_prompt: string = g: + ->get('helptoc', {}) + ->get('shell_prompt', '^\w\+@\w\+:\+\$\s') + if new_prompt != SHELL_PROMPT + SHELL_PROMPT = new_prompt + # invalidate cache: user config has changed + unlet! b:toc + endif +enddef + +UpdateUserSettings() # Init {{{1 @@ -141,6 +152,8 @@ export def Open() #{{{2 return endif + UpdateUserSettings() + # invalidate the cache if the buffer's contents has changed if exists('b:toc') && &filetype != 'man' if b:toc.changedtick != b:changedtick -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/vim_dev/E1tHlf5-000qYI-6O%40256bit.org.