diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2022-11-13 14:46:13 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2022-11-13 14:46:13 +1100 |
commit | a905a28e41d7b0d4c72c78b9b65f45f511c49fd1 (patch) | |
tree | 1faf157ba8b09e77e5035f6c804dd6c767aa7212 /pkg | |
parent | 5964472ec16edf08d1dfc5ed70ea1195f983da82 (diff) |
better hiding of underscores
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/gui/style/basic_styles.go | 9 | ||||
-rw-r--r-- | pkg/gui/style/text_style.go | 18 |
2 files changed, 13 insertions, 14 deletions
diff --git a/pkg/gui/style/basic_styles.go b/pkg/gui/style/basic_styles.go index 61db335e3..e37e90001 100644 --- a/pkg/gui/style/basic_styles.go +++ b/pkg/gui/style/basic_styles.go @@ -1,20 +1,11 @@ package style import ( - "os" "text/template" "github.com/gookit/color" ) -// See https://github.com/xtermjs/xterm.js/issues/4238 -// VSCode is soon to fix this in an upcoming update. -// Once that's done, we can scrap the HIDE_UNDERSCORES variable -// duplicating because init() isn't always called when we need it -func init() { - HIDE_UNDERSCORES = os.Getenv("TERM_PROGRAM") == "vscode" -} - var ( FgWhite = FromBasicFg(color.FgWhite) FgLightWhite = FromBasicFg(color.FgLightWhite) diff --git a/pkg/gui/style/text_style.go b/pkg/gui/style/text_style.go index 14fac379b..96d43a8f0 100644 --- a/pkg/gui/style/text_style.go +++ b/pkg/gui/style/text_style.go @@ -27,13 +27,21 @@ import ( // a string, we derive it when a new TextStyle is created and store it in the // `style` field. -var HIDE_UNDERSCORES bool - // See https://github.com/xtermjs/xterm.js/issues/4238 // VSCode is soon to fix this in an upcoming update. // Once that's done, we can scrap the HIDE_UNDERSCORES variable -func init() { - HIDE_UNDERSCORES = os.Getenv("TERM_PROGRAM") == "vscode" +var ( + underscoreEnvChecked bool + hideUnderscores bool +) + +func hideUnderScores() bool { + if !underscoreEnvChecked { + hideUnderscores = os.Getenv("TERM_PROGRAM") == "vscode" + underscoreEnvChecked = true + } + + return hideUnderscores } type TextStyle struct { @@ -75,7 +83,7 @@ func (b TextStyle) SetBold() TextStyle { } func (b TextStyle) SetUnderline() TextStyle { - if HIDE_UNDERSCORES { + if hideUnderScores() { return b } |