mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-109893 Formatting of LONG strings in comments
This commit is contained in:
@@ -605,4 +605,17 @@ public class JavadocFormatterTest extends AbstractJavaFormatterTest {
|
||||
|
||||
doTextTest(before, after);
|
||||
}
|
||||
|
||||
public void testDoNotWrapLongLineCommentWithSpaceInStart() throws Exception {
|
||||
getSettings().KEEP_FIRST_COLUMN_COMMENT = true;
|
||||
getSettings().WRAP_LONG_LINES = true;
|
||||
getSettings().getRootSettings().RIGHT_MARGIN = 200;
|
||||
String before = "public class JiraIssue {\n" +
|
||||
"\n" +
|
||||
" public static void main(String[] args) {\n" +
|
||||
"// AAAMIIGgIBADANBgkqhkiG9w0BAQEFAASCBugwgsdfssdflkldkflskdfsdkfjskdlfjdskjfksdjfksdjfkjsdkfjsdkfjgbkAgEAAoIBgQCZfKds4XjFWIU8D4OqCYJ0TkAkKPVV96v2l6PuMBNbON3ndHCVvwoJOJnopfbtFro9eCTCUC9MlAUZBAVdCbPVi3ioqaEN\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
doTextTest(before, before);
|
||||
}
|
||||
}
|
||||
+12
-4
@@ -491,9 +491,17 @@ public class CodeFormatterFacade {
|
||||
editor.getCaretModel().moveToOffset(wrapOffset);
|
||||
emulateEnter(editor, project, shifts);
|
||||
|
||||
// We know that number of lines is just increased, hence, update the data accordingly.
|
||||
maxLine += shifts[0];
|
||||
endOffsetToUse += shifts[1];
|
||||
//If number of inserted symbols on new line after wrapping more or equal then symbols left on previous line
|
||||
//there was no point to wrapping it, so reverting to before wrapping version
|
||||
if (shifts[1] - 1 >= wrapOffset - startLineOffset) {
|
||||
document.deleteString(wrapOffset, wrapOffset + shifts[1]);
|
||||
}
|
||||
else {
|
||||
// We know that number of lines is just increased, hence, update the data accordingly.
|
||||
maxLine += shifts[0];
|
||||
endOffsetToUse += shifts[1];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -504,7 +512,7 @@ public class CodeFormatterFacade {
|
||||
* @param project target project
|
||||
* @param shifts two-elements array which is expected to be filled with the following info:
|
||||
* 1. The first element holds added lines number;
|
||||
* 2. The second element holds added symbols number;
|
||||
* 2. The second element holds added symbols number;
|
||||
*/
|
||||
private static void emulateEnter(@NotNull final Editor editor, @NotNull Project project, int[] shifts) {
|
||||
final DataContext dataContext = prepareContext(editor.getComponent(), project);
|
||||
|
||||
Reference in New Issue
Block a user