Skip to content

Commit 3dae59d

Browse files
committed
properly load settings
1 parent f2c6daf commit 3dae59d

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

modules/highlight/highlight.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"bytes"
1111
"path/filepath"
1212
"strings"
13+
"sync"
1314

1415
"code.gitea.io/gitea/modules/log"
1516
"code.gitea.io/gitea/modules/setting"
@@ -21,14 +22,18 @@ import (
2122
var (
2223
// For custom user mapping
2324
highlightMapping = map[string]string{}
25+
26+
once sync.Once
2427
)
2528

2629
// NewContext loads highlight map
2730
func NewContext() {
28-
keys := setting.Cfg.Section("highlight.mapping").Keys()
29-
for i := range keys {
30-
highlightMapping[keys[i].Name()] = keys[i].Value()
31-
}
31+
once.Do(func() {
32+
keys := setting.Cfg.Section("highlight.mapping").Keys()
33+
for i := range keys {
34+
highlightMapping[keys[i].Name()] = keys[i].Value()
35+
}
36+
})
3237
}
3338

3439
// Code returns a HTML version of code string with chroma syntax highlighting classes

0 commit comments

Comments
 (0)