From e2d13c70388b83b84af3eab42f45e40af796d984 Mon Sep 17 00:00:00 2001 From: Hexah Date: Wed, 1 Apr 2020 11:53:42 +0200 Subject: [PATCH] Disable indentation in for loops --- App/AssemblyInfo1.cs | 2 +- UI/Components/EditorElement.xaml.cs | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/App/AssemblyInfo1.cs b/App/AssemblyInfo1.cs index aa47bdc6..38f2a283 100644 --- a/App/AssemblyInfo1.cs +++ b/App/AssemblyInfo1.cs @@ -33,5 +33,5 @@ #if (DEBUG) [assembly: AssemblyVersion("1.13.*")] #else -[assembly: AssemblyVersion("1.3.4.3")] +[assembly: AssemblyVersion("1.3.4.4")] #endif diff --git a/UI/Components/EditorElement.xaml.cs b/UI/Components/EditorElement.xaml.cs index acd00ed0..3a6e9dd4 100644 --- a/UI/Components/EditorElement.xaml.cs +++ b/UI/Components/EditorElement.xaml.cs @@ -530,11 +530,19 @@ private void TextArea_TextEntered(object sender, TextCompositionEventArgs e) if (e.Text == ";") if (editor.CaretOffset >= 0) { + var line = editor.Document.GetLineByOffset(editor.CaretOffset); - var leadingIndentation = - editor.Document.GetText(TextUtilities.GetLeadingWhitespace(editor.Document, line)); - var newLineStr = leadingIndentation + SPSyntaxTidy.TidyUp(editor.Document.GetText(line)).Trim(); - editor.Document.Replace(line, newLineStr); + var text = editor.Document.GetText(line); + + // TODO: Poor way to fix this but atm I have no idea on how to fix this properly + if (!text.Contains("for")) + { + var leadingIndentation = + editor.Document.GetText(TextUtilities.GetLeadingWhitespace(editor.Document, line)); + var newLineStr = leadingIndentation + + SPSyntaxTidy.TidyUp(text).Trim(); + editor.Document.Replace(line, newLineStr); + } } switch (e.Text)