@@ -19,13 +19,12 @@ internal class AbsoluteCodeLine
1919 private static readonly Regex ProcedureEndRegex = new Regex ( @"^End\s(Sub|Function|Property)" ) ;
2020 private static readonly Regex TypeEnumStartRegex = new Regex ( @"^(Public\s|Private\s)?(Enum\s|Type\s)" ) ;
2121 private static readonly Regex TypeEnumEndRegex = new Regex ( @"^End\s(Enum|Type)" ) ;
22- private static readonly Regex InProcedureInRegex = new Regex ( @"^(Else)?If\s.*\sThen$|^(Else)?If\s.*\sThen\s.*\sElse$|^ Else$|^Case\s|^With|^For\s|^Do$|^Do\s|^While$|^While\s|^Select Case" ) ;
23- private static readonly Regex InProcedureOutRegex = new Regex ( @"^( Else)?If\s.*\sThen\s.*(?<!\sElse)$|^Else$|ElseIf\s.*\sThen$ |^Case\s|^End With|^Next\s|^Next$|^Loop$|^Loop\s|^Wend$|^End If$|^End Select" ) ;
22+ private static readonly Regex InProcedureInRegex = new Regex ( @"^(Else)?If\s.*\sThen$|^Else$|^Case\s|^With|^For\s|^Do$|^Do\s|^While$|^While\s|^Select Case" ) ;
23+ private static readonly Regex InProcedureOutRegex = new Regex ( @"^Else(If)? |^Case\s|^End With|^Next\s|^Next$|^Loop$|^Loop\s|^Wend$|^End If$|^End Select" ) ;
2424 private static readonly Regex DeclarationRegex = new Regex ( @"^(Dim|Const|Static|Public|Private)\s.*\sAs\s" ) ;
2525 private static readonly Regex PrecompilerInRegex = new Regex ( @"^#(Else)?If\s.+Then$|^#Else$" ) ;
2626 private static readonly Regex PrecompilerOutRegex = new Regex ( @"^#ElseIf\s.+Then|^#Else$|#End\sIf$" ) ;
27- private static readonly Regex SingleLineIfRegex = new Regex ( @"^If\s.*\sThen\s.*(?<!\sElse)$" ) ;
28- private static readonly Regex SingleLineElseIfRegex = new Regex ( @"^ElseIf\s.*\sThen\s.*(?<!\sElse)$" ) ;
27+ private static readonly Regex SingleLineElseIfRegex = new Regex ( @"^ElseIf\s.*\sThen\s.*" ) ;
2928
3029 private readonly IIndenterSettings _settings ;
3130 private uint _lineNumber ;
@@ -181,7 +180,6 @@ public int Outdents
181180 var outs = _segments . Count ( s => InProcedureOutRegex . IsMatch ( s . Trim ( ) ) ) + ( IsProcedureEnd && _settings . IndentEntireProcedureBody ? 1 : 0 ) + adjust ;
182181
183182 outs -= MultipleCaseAdjustment ( ) ;
184- outs -= _segments . Count ( s => SingleLineIfRegex . IsMatch ( s ) ) ;
185183
186184 if ( _settings . IndentCompilerDirectives && PrecompilerOutRegex . IsMatch ( _segments [ 0 ] . Trim ( ) ) )
187185 {
@@ -246,6 +244,11 @@ public string Indent(int indents, bool atProcStart, bool absolute = false)
246244 }
247245 }
248246
247+ public override string ToString ( )
248+ {
249+ return Original ;
250+ }
251+
249252 private void AlignDims ( int postition )
250253 {
251254 if ( ! DeclarationRegex . IsMatch ( _segments [ 0 ] ) || IsProcedureStart ) return ;
0 commit comments