@@ -10,7 +10,7 @@ namespace Rubberduck.SmartIndenter
10
10
internal class AbsoluteCodeLine
11
11
{
12
12
private const string StupidLineEnding = ": _" ;
13
- private static readonly Regex LineNumberRegex = new Regex ( @"^(?<number>(-?\d+)|(&H[0-9A-F]{1,8}))\s+(?<code>.*)" , RegexOptions . ExplicitCapture ) ;
13
+ private static readonly Regex LineNumberRegex = new Regex ( @"^(?<number>(-?\d+)|(&H[0-9A-F]{1,8}))(?<separator>:)? \s+(?<code>.*)" , RegexOptions . ExplicitCapture ) ;
14
14
private static readonly Regex EndOfLineCommentRegex = new Regex ( @"^(?!(Rem\s)|('))(?<code>[^']*)(\s(?<comment>'.*))$" , RegexOptions . ExplicitCapture ) ;
15
15
private static readonly Regex ProcedureStartRegex = new Regex ( @"^(Public\s|Private\s|Friend\s)?(Static\s)?(Sub|Function|Property\s(Let|Get|Set))\s" ) ;
16
16
private static readonly Regex ProcedureStartIgnoreRegex = new Regex ( @"^[LR]?Set\s|^Let\s|^(Public|Private)\sDeclare\s(Function|Sub)" ) ;
@@ -26,6 +26,7 @@ internal class AbsoluteCodeLine
26
26
27
27
private readonly IIndenterSettings _settings ;
28
28
private int _lineNumber ;
29
+ private bool _lineNumberSeparator ;
29
30
private bool _numbered ;
30
31
private string _code ;
31
32
private readonly bool _stupidLineEnding ;
@@ -69,6 +70,7 @@ private void ExtractLineNumber()
69
70
{
70
71
_code = match . Groups [ "code" ] . Value ;
71
72
_numbered = true ;
73
+ _lineNumberSeparator = match . Groups [ "separator" ] . Value != string . Empty ;
72
74
var number = match . Groups [ "number" ] . Value ;
73
75
if ( ! int . TryParse ( number , out _lineNumber ) )
74
76
{
@@ -254,14 +256,15 @@ public string Indent(int indents, bool atProcStart, bool absolute = false)
254
256
}
255
257
256
258
var number = _numbered ? _lineNumber . ToString ( CultureInfo . InvariantCulture ) : string . Empty ;
257
- var gap = Math . Max ( ( absolute ? indents : _settings . IndentSpaces * indents ) - number . Length , number . Length > 0 ? 1 : 0 ) ;
259
+ var separator = _lineNumberSeparator ? ":" : string . Empty ;
260
+ var gap = Math . Max ( ( absolute ? indents : _settings . IndentSpaces * indents ) - number . Length - separator . Length , number . Length + separator . Length > 0 ? 1 : 0 ) ;
258
261
if ( _settings . AlignDims && ( IsDeclaration || IsDeclarationContinuation ) )
259
262
{
260
263
AlignDims ( gap ) ;
261
264
}
262
265
263
266
var code = string . Join ( ": " , _segments ) ;
264
- code = string . Join ( string . Empty , number , new string ( ' ' , gap ) , code ) ;
267
+ code = string . Join ( string . Empty , number , separator , new string ( ' ' , gap ) , code ) ;
265
268
if ( string . IsNullOrEmpty ( EndOfLineComment ) )
266
269
{
267
270
return _escaper . UnescapeIndented ( code + ( _stupidLineEnding ? StupidLineEnding : string . Empty ) ) ;
0 commit comments