diff --git a/EditorContext/EditorContext.cs b/EditorContext/EditorContext.cs index 75783bd..7d50e7d 100644 --- a/EditorContext/EditorContext.cs +++ b/EditorContext/EditorContext.cs @@ -14,6 +14,7 @@ public abstract class EditorContext public bool CanFormat = false; public bool CanAutocomplete = false; public bool CanRun = false; + public bool CanSyntaxHighlight = false; public ConcurrentDictionary Errors = new ConcurrentDictionary(); public ConcurrentDictionary ColumnErrors = new ConcurrentDictionary(); public Dictionary pointColorDict = new Dictionary(); diff --git a/EditorContext/JSONEditorContext.cs b/EditorContext/JSONEditorContext.cs index 85fc42a..ef0a2db 100644 --- a/EditorContext/JSONEditorContext.cs +++ b/EditorContext/JSONEditorContext.cs @@ -16,6 +16,7 @@ public JSONEditorContext(int TabWidth) { _tabWidth = TabWidth; CanFormat = true; + CanSyntaxHighlight = true; } public Terminal.Gui.Color GetColor(JsonToken token) { diff --git a/EditorContext/PowerShellEditorContext.cs b/EditorContext/PowerShellEditorContext.cs index 5b77f36..6496536 100644 --- a/EditorContext/PowerShellEditorContext.cs +++ b/EditorContext/PowerShellEditorContext.cs @@ -21,7 +21,8 @@ public PowerShellEditorContext(int TabWidth, Runspace Runspace) CanAutocomplete = true; CanRun = true; - + CanSyntaxHighlight = true; + // verify that psscriptanalyzer is available for formatting using (var powerShell = PowerShell.Create(RunspaceMode.CurrentRunspace)) { diff --git a/EditorTextView.cs b/EditorTextView.cs index 23fa94b..0cfaace 100644 --- a/EditorTextView.cs +++ b/EditorTextView.cs @@ -17,6 +17,7 @@ public class EditorTextView : TextView private EditorContext editorContext; public bool CanFormat = false; public bool CanRun = false; + public bool CanSyntaxHighlight = false; public LanguageEnum _language = LanguageEnum.Powershell; public EditorTextView(Runspace runspace) { @@ -51,11 +52,13 @@ public void SetLanguage(LanguageEnum language) { CanFormat = editorContext.CanFormat; CanRun = editorContext.CanRun; + CanSyntaxHighlight = editorContext.CanSyntaxHighlight; } else { CanFormat = false; CanRun = false; + CanSyntaxHighlight = false; } } public void Format() diff --git a/ShowEditorCommand.cs b/ShowEditorCommand.cs index 8bddaf2..52c318d 100644 --- a/ShowEditorCommand.cs +++ b/ShowEditorCommand.cs @@ -98,8 +98,8 @@ protected override void ProcessRecord() }), new MenuBarItem("_View", new [] { - new MenuItem("Errors", "", () => ErrorDialog.Show(_runspace)), - new MenuItem("Syntax Errors", "", () => SyntaxErrorDialog.Show(textEditor.Errors)), + new MenuItem("Errors", "", () => { if (textEditor._language == LanguageEnum.Powershell) ErrorDialog.Show(_runspace); }), + new MenuItem("Syntax Errors", "", () => { if (textEditor.CanSyntaxHighlight) SyntaxErrorDialog.Show(textEditor.Errors); }), //new MenuItem("History", "", () => HistoryDialog.Show(_runspace)) }), new MenuBarItem("_Debug", new []