@@ -144,7 +144,8 @@ public class ASPrettyPrinter
144
144
private int mBraceStyleSetting = BraceStyle_Adobe ;
145
145
private bool mUseGlobalNewlineBeforeBraceSetting = true ;
146
146
private int mAdvancedNewlineBeforeBraceSettings ;
147
-
147
+
148
+ private bool mIndentMultilineComments = true ;
148
149
private bool mUseLineCommentWrapping = false ;
149
150
private bool mUseDocCommentWrapping = false ;
150
151
private bool mUseMLCommentWrapping = false ;
@@ -1254,8 +1255,7 @@ public void emit(IToken tok)
1254
1255
if ( isKeepRelativeCommentIndent ( ) )
1255
1256
{
1256
1257
//find original indent
1257
- String lineData = "" ;
1258
- lineData += t . Text ;
1258
+ String lineData = t . Text ;
1259
1259
int prevLineEnd = mSourceData . LastIndexOf ( '\n ' , ( ( CommonToken ) t ) . StartIndex ) ;
1260
1260
if ( prevLineEnd < 0 )
1261
1261
prevLineEnd = 0 ;
@@ -1283,17 +1283,26 @@ public void emit(IToken tok)
1283
1283
{
1284
1284
if ( onLastLine && data . StartsWith ( "*/" ) ) //if we're on the last line and there's more than one line
1285
1285
{
1286
- indentAmount ++ ;
1286
+ if ( mIndentMultilineComments ) indentAmount += 1 ;
1287
+ else indentAmount += 0 ;
1287
1288
}
1288
1289
else
1289
1290
{
1290
- //on a middle line, we have 2 cases. If the line starts with an asterisk, then attempt to line the
1291
- //asterisk up with the asterisk on the first line. Otherwise, indent the text to the right of the open asterisk.
1292
- String nextLine = data ;
1293
- if ( nextLine . Length > 0 && nextLine [ 0 ] == '*' )
1294
- indentAmount += 1 ;
1295
- else
1296
- indentAmount += 3 ;
1291
+ //on a middle line, we have 2 cases. If the line starts with an asterisk, then attempt to line the
1292
+ //asterisk up with the asterisk on the first line. Otherwise, indent the text to the right of the open asterisk.
1293
+ //String nextLine=data;
1294
+ //if (nextLine.Length>0 && nextLine[0]=='*')
1295
+ //indentAmount+=1;
1296
+ //else
1297
+ //indentAmount+=3;
1298
+ // FIXED: Multiline comment indent support added
1299
+ String nextLine = data ;
1300
+ if ( nextLine . Length > 0 && nextLine [ 0 ] == '*' )
1301
+ {
1302
+ if ( mIndentMultilineComments ) indentAmount += 1 ;
1303
+ else indentAmount += 0 ;
1304
+ }
1305
+ else indentAmount += 3 ;
1297
1306
}
1298
1307
}
1299
1308
}
@@ -3516,6 +3525,16 @@ public void saveWrapChar(IToken op, int breakType, bool breakBefore, bool indent
3516
3525
info . addWrapChar ( op , mExpressionWrapData . Count , mOutputBuffer . Length - op . Text . Length , breakType , breakBefore , indentToFirstParm , firstParmLocation , getCurrentIndent ( ) , commaContextType ) ;
3517
3526
}
3518
3527
3528
+ public bool isIndentMultilineComments ( )
3529
+ {
3530
+ return mIndentMultilineComments ;
3531
+ }
3532
+
3533
+ public void setIndentMultilineComments ( bool indentMultilineComments )
3534
+ {
3535
+ mIndentMultilineComments = indentMultilineComments ;
3536
+ }
3537
+
3519
3538
public int getHangingIndentTabs ( ) {
3520
3539
return mHangingIndentTabs ;
3521
3540
}
@@ -3954,6 +3973,7 @@ public bool addOpenBrace(ITokenStream input, int braceCode)
3954
3973
3955
3974
private List < StatementBraceInfo > mAddBraceStack ;
3956
3975
private List < StatementBraceInfo > mCompletedBraceInfos ;
3976
+
3957
3977
public void addOpenBrace ( IToken nextToken , int braceCode )
3958
3978
{
3959
3979
// addBracePart(nextToken, braceCode, "{");
0 commit comments