@@ -10,6 +10,17 @@ import (
1010 "go.uber.org/zap"
1111)
1212
13+ // configSnapshot returns the current config pointer under a read lock.
14+ // Callers should use the returned pointer for all reads within a single
15+ // logical operation to avoid seeing a partially-updated config.
16+ func (a * App ) configSnapshot () * config.Config {
17+ a .configMu .RLock ()
18+ cfg := a .config
19+ a .configMu .RUnlock ()
20+
21+ return cfg
22+ }
23+
1324// SetEnabled sets the enabled state of the application.
1425func (a * App ) SetEnabled (v bool ) {
1526 a .appState .SetEnabled (v )
@@ -27,22 +38,28 @@ func (a *App) ToggleEnabled() {
2738
2839// HintsEnabled returns true if hints are enabled.
2940func (a * App ) HintsEnabled () bool {
30- return a .config != nil && a .config .Hints .Enabled
41+ cfg := a .configSnapshot ()
42+
43+ return cfg != nil && cfg .Hints .Enabled
3144}
3245
3346// GridEnabled returns true if grid is enabled.
3447func (a * App ) GridEnabled () bool {
35- return a .config != nil && a .config .Grid .Enabled
48+ cfg := a .configSnapshot ()
49+
50+ return cfg != nil && cfg .Grid .Enabled
3651}
3752
3853// RecursiveGridEnabled returns true if recursive-grid is enabled.
3954func (a * App ) RecursiveGridEnabled () bool {
40- return a .config != nil && a .config .RecursiveGrid .Enabled
55+ cfg := a .configSnapshot ()
56+
57+ return cfg != nil && cfg .RecursiveGrid .Enabled
4158}
4259
4360// Config returns the application configuration.
4461func (a * App ) Config () * config.Config {
45- return a .config
62+ return a .configSnapshot ()
4663}
4764
4865// Logger returns the application logger.
@@ -71,7 +88,11 @@ func (a *App) Renderer() *ui.OverlayRenderer {
7188
7289// GetConfigPath returns the config path.
7390func (a * App ) GetConfigPath () string {
74- return a .ConfigPath
91+ a .configMu .RLock ()
92+ p := a .ConfigPath
93+ a .configMu .RUnlock ()
94+
95+ return p
7596}
7697
7798// SetHintOverlayNeedsRefresh sets the hint overlay needs refresh flag.
0 commit comments