diff --git a/src/PowerShellEditorServices.Protocol/Server/LanguageServerSettings.cs b/src/PowerShellEditorServices.Protocol/Server/LanguageServerSettings.cs index 8ce27bcfb..369c5ee45 100644 --- a/src/PowerShellEditorServices.Protocol/Server/LanguageServerSettings.cs +++ b/src/PowerShellEditorServices.Protocol/Server/LanguageServerSettings.cs @@ -190,6 +190,7 @@ public CodeFormattingSettings(CodeFormattingSettings codeFormattingSettings) } } + public bool AutoCorrectAliases { get; set; } public CodeFormattingPreset Preset { get; set; } public bool OpenBraceOnSameLine { get; set; } public bool NewLineAfterOpenBrace { get; set; } @@ -249,16 +250,7 @@ public Hashtable GetPSSASettingsHashtable( private Hashtable GetCustomPSSASettingsHashtable(int tabSize, bool insertSpaces) { - return new Hashtable - { - {"IncludeRules", new string[] { - "PSPlaceCloseBrace", - "PSPlaceOpenBrace", - "PSUseConsistentWhitespace", - "PSUseConsistentIndentation", - "PSAlignAssignmentStatement" - }}, - {"Rules", new Hashtable { + var ruleConfigurations = new Hashtable { {"PSPlaceOpenBrace", new Hashtable { {"Enable", true}, {"OnSameLine", OpenBraceOnSameLine}, @@ -292,7 +284,25 @@ private Hashtable GetCustomPSSASettingsHashtable(int tabSize, bool insertSpaces) {"PSUseCorrectCasing", new Hashtable { {"Enable", UseCorrectCasing} }}, - }} + }; + if (AutoCorrectAliases) + { + ruleConfigurations.Add("PSAvoidUsingCmdletAliases", new Hashtable()); + } + + return new Hashtable + { + {"IncludeRules", new string[] { + "PSPlaceCloseBrace", + "PSPlaceOpenBrace", + "PSUseConsistentWhitespace", + "PSUseConsistentIndentation", + "PSAlignAssignmentStatement", + "PSAvoidUsingCmdletAliases", + }}, + { + "Rules", ruleConfigurations + }, }; } }