Skip to content

Commit a2a4c86

Browse files
committed
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. [1]: vim#10446 (comment) Best-viewed-with: --ignore-space-change
1 parent 3c2596a commit a2a4c86

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

runtime/pack/dist/opt/helptoc/autoload/helptoc.vim

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@ vim9script noclear
22

33
# Config {{{1
44

5-
const SHELL_PROMPT: string = g:
6-
->get('helptoc', {})
7-
->get('shell_prompt', '^\w\+@\w\+:\f\+\$\s')
5+
var SHELL_PROMPT: string = ''
6+
7+
def UpdateUserSettings() #{{{2
8+
SHELL_PROMPT = g:
9+
->get('helptoc', {})
10+
->get('shell_prompt', '^\w\+@\w\+:\f\+\$\s')
11+
enddef
12+
13+
UpdateUserSettings()
814

915
# Init {{{1
1016

@@ -200,6 +206,7 @@ enddef
200206
#}}}1
201207
# Core {{{1
202208
def SetToc() #{{{2
209+
UpdateUserSettings()
203210
var toc: dict<any> = {entries: []}
204211
var type: string = GetType()
205212
toc.changedtick = b:changedtick

0 commit comments

Comments
 (0)