mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2024-12-27 11:59:40 -08:00
parent
6a6715faec
commit
c98c1b5425
|
@ -116,11 +116,14 @@ func (l *language) string() string {
|
|||
}
|
||||
|
||||
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
|
||||
}
|
||||
l.loadLanguageContext()
|
||||
displayMode := l.props.getString(DisplayMode, DisplayModeFiles)
|
||||
switch displayMode {
|
||||
case DisplayModeAlways:
|
||||
return true
|
||||
|
|
|
@ -438,6 +438,39 @@ func TestLanguageHyperlinkEnabledLessParamInTemplate(t *testing.T) {
|
|||
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) {
|
||||
props := map[Property]interface{}{
|
||||
EnableHyperlink: true,
|
||||
|
|
Loading…
Reference in a new issue