Skip to content

Commit

Permalink
added option to also auto enable the extension when a suo entry is fo…
Browse files Browse the repository at this point in the history
…und and made this the default (Fixes #160)
  • Loading branch information
Irame committed Feb 25, 2024
1 parent bbc8bf4 commit dfd28ab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion SmartCmdArgs/SmartCmdArgs.Shared/CmdArgsOptionPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public enum InactiveDisableMode
[TypeConverter(typeof(EnumDescriptionTypeConverter))]
public enum EnableBehaviour
{
[Description("Enable if a *.arg.json file or an entry in the *.suo file is found")]
EnableIfArgJsonOrSuoEntryIsFound,

[Description("Enable if a *.arg.json file is found")]
EnableIfArgJsonIsFound,

Expand Down Expand Up @@ -79,7 +82,7 @@ public CmdArgsOptionPage() : base()
[Category("General")]
[DisplayName("Enable Behaviour")]
[Description("Choose whether the extension should enable automatically or ask the user for permission first.")]
[DefaultValue(EnableBehaviour.EnableIfArgJsonIsFound)]
[DefaultValue(EnableBehaviour.EnableIfArgJsonOrSuoEntryIsFound)]
public EnableBehaviour EnableBehaviour
{
get => _enableBehaviour;
Expand Down
10 changes: 8 additions & 2 deletions SmartCmdArgs/SmartCmdArgs.Shared/Services/LifeCycleService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,17 @@ private bool GetDefaultEnabled()
return false;

case EnableBehaviour.EnableIfArgJsonIsFound:
return optionsSettings.VcsSupportEnabled
&& fileStorage.GetAllArgJsonFileNames().Any(File.Exists);
return JsonFileExists();

case EnableBehaviour.EnableIfArgJsonOrSuoEntryIsFound:
return JsonFileExists() || suoDataService.SuoDataJson?.ProjectArguments.Any() == true;

default: return false;
}

bool JsonFileExists() =>
optionsSettings.VcsSupportEnabled
&& fileStorage.GetAllArgJsonFileNames().Any(File.Exists);
}

public void UpdateDisabledScreen()
Expand Down

0 comments on commit dfd28ab

Please sign in to comment.