mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-28 20:39:40 -08:00
parent
6a6715faec
commit
c98c1b5425
|
@ -116,11 +116,14 @@ func (l *language) string() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *language) enabled() bool {
|
func (l *language) enabled() bool {
|
||||||
if l.env.getcwd() == l.env.homeDir() {
|
inHomeDir := func() bool {
|
||||||
|
return l.env.getcwd() == l.env.homeDir()
|
||||||
|
}
|
||||||
|
displayMode := l.props.getString(DisplayMode, DisplayModeFiles)
|
||||||
|
if inHomeDir() && displayMode != DisplayModeAlways {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
l.loadLanguageContext()
|
l.loadLanguageContext()
|
||||||
displayMode := l.props.getString(DisplayMode, DisplayModeFiles)
|
|
||||||
switch displayMode {
|
switch displayMode {
|
||||||
case DisplayModeAlways:
|
case DisplayModeAlways:
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -438,6 +438,39 @@ func TestLanguageHyperlinkEnabledLessParamInTemplate(t *testing.T) {
|
||||||
assert.Equal(t, "[1.3.307](https://unicor.org/doc/1)", lang.string())
|
assert.Equal(t, "[1.3.307](https://unicor.org/doc/1)", lang.string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestLanguageEnabledInHome(t *testing.T) {
|
||||||
|
cases := []struct {
|
||||||
|
Case string
|
||||||
|
DisplayMode string
|
||||||
|
ExpectedEnabled bool
|
||||||
|
}{
|
||||||
|
{Case: "Always enabled", DisplayMode: DisplayModeAlways, ExpectedEnabled: true},
|
||||||
|
{Case: "Context disabled", DisplayMode: DisplayModeContext, ExpectedEnabled: false},
|
||||||
|
}
|
||||||
|
for _, tc := range cases {
|
||||||
|
props := map[Property]interface{}{
|
||||||
|
DisplayMode: tc.DisplayMode,
|
||||||
|
}
|
||||||
|
args := &languageArgs{
|
||||||
|
commands: []*cmd{
|
||||||
|
{
|
||||||
|
executable: "uni",
|
||||||
|
args: []string{"--version"},
|
||||||
|
regex: `(?P<version>((?P<major>[0-9]+).(?P<minor>[0-9]+).(?P<patch>[0-9]+)))`,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
extensions: []string{uni, corn},
|
||||||
|
enabledExtensions: []string{corn},
|
||||||
|
enabledCommands: []string{"corn"},
|
||||||
|
version: universion,
|
||||||
|
properties: props,
|
||||||
|
inHome: true,
|
||||||
|
}
|
||||||
|
lang := bootStrapLanguageTest(args)
|
||||||
|
assert.Equal(t, tc.ExpectedEnabled, lang.enabled(), tc.Case)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestLanguageHyperlinkEnabledMoreParamInTemplate(t *testing.T) {
|
func TestLanguageHyperlinkEnabledMoreParamInTemplate(t *testing.T) {
|
||||||
props := map[Property]interface{}{
|
props := map[Property]interface{}{
|
||||||
EnableHyperlink: true,
|
EnableHyperlink: true,
|
||||||
|
|
Loading…
Reference in a new issue