@@ -19,13 +19,12 @@ internal class AbsoluteCodeLine
19
19
private static readonly Regex ProcedureEndRegex = new Regex ( @"^End\s(Sub|Function|Property)" ) ;
20
20
private static readonly Regex TypeEnumStartRegex = new Regex ( @"^(Public\s|Private\s)?(Enum\s|Type\s)" ) ;
21
21
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" ) ;
24
24
private static readonly Regex DeclarationRegex = new Regex ( @"^(Dim|Const|Static|Public|Private)\s.*\sAs\s" ) ;
25
25
private static readonly Regex PrecompilerInRegex = new Regex ( @"^#(Else)?If\s.+Then$|^#Else$" ) ;
26
26
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.*" ) ;
29
28
30
29
private readonly IIndenterSettings _settings ;
31
30
private uint _lineNumber ;
@@ -181,7 +180,6 @@ public int Outdents
181
180
var outs = _segments . Count ( s => InProcedureOutRegex . IsMatch ( s . Trim ( ) ) ) + ( IsProcedureEnd && _settings . IndentEntireProcedureBody ? 1 : 0 ) + adjust ;
182
181
183
182
outs -= MultipleCaseAdjustment ( ) ;
184
- outs -= _segments . Count ( s => SingleLineIfRegex . IsMatch ( s ) ) ;
185
183
186
184
if ( _settings . IndentCompilerDirectives && PrecompilerOutRegex . IsMatch ( _segments [ 0 ] . Trim ( ) ) )
187
185
{
@@ -246,6 +244,11 @@ public string Indent(int indents, bool atProcStart, bool absolute = false)
246
244
}
247
245
}
248
246
247
+ public override string ToString ( )
248
+ {
249
+ return Original ;
250
+ }
251
+
249
252
private void AlignDims ( int postition )
250
253
{
251
254
if ( ! DeclarationRegex . IsMatch ( _segments [ 0 ] ) || IsProcedureStart ) return ;
0 commit comments