@@ -10,8 +10,6 @@ namespace Rubberduck.SmartIndenter
10
10
internal class AbsoluteCodeLine
11
11
{
12
12
private const string StupidLineEnding = ": _" ;
13
- private static readonly Regex StringReplaceRegex = new Regex ( StringLiteralAndBracketEscaper . StringPlaceholder . ToString ( CultureInfo . InvariantCulture ) ) ;
14
- private static readonly Regex BracketReplaceRegex = new Regex ( StringLiteralAndBracketEscaper . BracketPlaceholder . ToString ( CultureInfo . InvariantCulture ) ) ;
15
13
private static readonly Regex LineNumberRegex = new Regex ( @"^(?<number>(-?\d+)|(&H[0-9A-F]{1,8}))\s+(?<code>.*)" , RegexOptions . ExplicitCapture ) ;
16
14
private static readonly Regex EndOfLineCommentRegex = new Regex ( @"^(?!(Rem\s)|('))(?<code>[^']*)(\s(?<comment>'.*))$" , RegexOptions . ExplicitCapture ) ;
17
15
private static readonly Regex ProcedureStartRegex = new Regex ( @"^(Public\s|Private\s|Friend\s)?(Static\s)?(Sub|Function|Property\s(Let|Get|Set))\s" ) ;
@@ -61,8 +59,8 @@ public AbsoluteCodeLine(string code, IIndenterSettings settings, AbsoluteCodeLin
61
59
ExtractLineNumber ( ) ;
62
60
ExtractEndOfLineComment ( ) ;
63
61
64
- _code = Regex . Replace ( _code , StringLiteralAndBracketEscaper . StringPlaceholder + "+" , StringLiteralAndBracketEscaper . StringPlaceholder . ToString ( CultureInfo . InvariantCulture ) ) ;
65
- _code = Regex . Replace ( _code , StringLiteralAndBracketEscaper . BracketPlaceholder + "+" , StringLiteralAndBracketEscaper . BracketPlaceholder . ToString ( CultureInfo . InvariantCulture ) ) . Trim ( ) ;
62
+ // _code = Regex.Replace(_code, StringLiteralAndBracketEscaper.StringPlaceholder + "+", StringLiteralAndBracketEscaper.StringPlaceholder.ToString(CultureInfo.InvariantCulture));
63
+ // _code = Regex.Replace(_code, StringLiteralAndBracketEscaper.BracketPlaceholder + "+", StringLiteralAndBracketEscaper.BracketPlaceholder.ToString(CultureInfo.InvariantCulture)).Trim();
66
64
_segments = _code . Split ( new [ ] { ": " } , StringSplitOptions . None ) ;
67
65
}
68
66
@@ -267,38 +265,29 @@ public string Indent(int indents, bool atProcStart, bool absolute = false)
267
265
}
268
266
269
267
var code = string . Join ( ": " , _segments ) ;
270
- if ( _escaper . EscapedStrings . Any ( ) )
271
- {
272
- code = _escaper . EscapedStrings . Aggregate ( code , ( current , literal ) => StringReplaceRegex . Replace ( current , literal , 1 ) ) ;
273
- }
274
- if ( _escaper . EscapedBrackets . Any ( ) )
275
- {
276
- code = _escaper . EscapedBrackets . Aggregate ( code , ( current , expr ) => BracketReplaceRegex . Replace ( current , expr , 1 ) ) ;
277
- }
278
-
279
268
code = string . Join ( string . Empty , number , new string ( ' ' , gap ) , code ) ;
280
269
if ( string . IsNullOrEmpty ( EndOfLineComment ) )
281
270
{
282
- return code + ( _stupidLineEnding ? StupidLineEnding : string . Empty ) ;
271
+ return _escaper . UnescapeIndented ( code + ( _stupidLineEnding ? StupidLineEnding : string . Empty ) ) ;
283
272
}
284
273
285
274
var position = Original . LastIndexOf ( EndOfLineComment , StringComparison . Ordinal ) ;
286
275
switch ( _settings . EndOfLineCommentStyle )
287
276
{
288
277
case EndOfLineCommentStyle . Absolute :
289
- return string . Format ( "{0}{1}{2}{3}" , code , new string ( ' ' , Math . Max ( position - code . Length , 1 ) ) ,
290
- EndOfLineComment , _stupidLineEnding ? StupidLineEnding : string . Empty ) ;
278
+ return _escaper . UnescapeIndented ( string . Format ( "{0}{1}{2}{3}" , code , new string ( ' ' , Math . Max ( position - code . Length , 1 ) ) ,
279
+ EndOfLineComment , _stupidLineEnding ? StupidLineEnding : string . Empty ) ) ;
291
280
case EndOfLineCommentStyle . SameGap :
292
281
var uncommented = Original . Substring ( 0 , position - 1 ) ;
293
- return string . Format ( "{0}{1}{2}{3}" , code , new string ( ' ' , uncommented . Length - uncommented . TrimEnd ( ) . Length + 1 ) ,
294
- EndOfLineComment , _stupidLineEnding ? StupidLineEnding : string . Empty ) ;
282
+ return _escaper . UnescapeIndented ( string . Format ( "{0}{1}{2}{3}" , code , new string ( ' ' , uncommented . Length - uncommented . TrimEnd ( ) . Length + 1 ) ,
283
+ EndOfLineComment , _stupidLineEnding ? StupidLineEnding : string . Empty ) ) ;
295
284
case EndOfLineCommentStyle . StandardGap :
296
- return string . Format ( "{0}{1}{2}{3}" , code , new string ( ' ' , _settings . IndentSpaces * 2 ) , EndOfLineComment ,
297
- _stupidLineEnding ? StupidLineEnding : string . Empty ) ;
285
+ return _escaper . UnescapeIndented ( string . Format ( "{0}{1}{2}{3}" , code , new string ( ' ' , _settings . IndentSpaces * 2 ) , EndOfLineComment ,
286
+ _stupidLineEnding ? StupidLineEnding : string . Empty ) ) ;
298
287
case EndOfLineCommentStyle . AlignInColumn :
299
288
var align = _settings . EndOfLineCommentColumnSpaceAlignment - code . Length ;
300
- return string . Format ( "{0}{1}{2}{3}" , code , new string ( ' ' , Math . Max ( align - 1 , 1 ) ) , EndOfLineComment ,
301
- _stupidLineEnding ? StupidLineEnding : string . Empty ) ;
289
+ return _escaper . UnescapeIndented ( string . Format ( "{0}{1}{2}{3}" , code , new string ( ' ' , Math . Max ( align - 1 , 1 ) ) , EndOfLineComment ,
290
+ _stupidLineEnding ? StupidLineEnding : string . Empty ) ) ;
302
291
default :
303
292
throw new InvalidEnumArgumentException ( ) ;
304
293
}
0 commit comments