mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-90457 Wrapping inserts two line breaks instead of one
'Wrap long lines' was applied not when right margin was actually reached but when 'right margin - X' columns number was exceeded. Preferred wrap position is calculated as before but no wrap is performed if a line doesn't actually exceed right margin
This commit is contained in:
+9
-1
@@ -337,6 +337,7 @@ public class CodeFormatterFacade {
|
||||
}
|
||||
}
|
||||
|
||||
boolean wrapLine = false;
|
||||
int preferredWrapPosition = Integer.MAX_VALUE;
|
||||
if (!hasTabs) {
|
||||
if (Math.min(endLineOffset, endOffsetToUse) - startLineOffset > mySettings.RIGHT_MARGIN) {
|
||||
@@ -355,7 +356,11 @@ public class CodeFormatterFacade {
|
||||
if (width + symbolWidth + FormatConstants.RESERVED_LINE_WRAP_WIDTH_IN_COLUMNS >= mySettings.RIGHT_MARGIN
|
||||
&& (Math.min(endLineOffset, endOffsetToUse) - i) >= FormatConstants.RESERVED_LINE_WRAP_WIDTH_IN_COLUMNS)
|
||||
{
|
||||
// Remember preferred position.
|
||||
preferredWrapPosition = i - 1;
|
||||
}
|
||||
if (width + symbolWidth >= mySettings.RIGHT_MARGIN) {
|
||||
wrapLine = true;
|
||||
break;
|
||||
}
|
||||
width += symbolWidth;
|
||||
@@ -383,13 +388,16 @@ public class CodeFormatterFacade {
|
||||
&& (Math.min(endLineOffset, endOffsetToUse) - i) >= FormatConstants.RESERVED_LINE_WRAP_WIDTH_IN_COLUMNS)
|
||||
{
|
||||
preferredWrapPosition = i - 1;
|
||||
}
|
||||
if (width + symbolWidth >= mySettings.RIGHT_MARGIN) {
|
||||
wrapLine = true;
|
||||
break;
|
||||
}
|
||||
x = newX;
|
||||
width += symbolWidth;
|
||||
}
|
||||
}
|
||||
if (preferredWrapPosition >= endLineOffset) {
|
||||
if (!wrapLine || preferredWrapPosition >= endLineOffset) {
|
||||
continue;
|
||||
}
|
||||
if (preferredWrapPosition >= endOffsetToUse) {
|
||||
|
||||
Reference in New Issue
Block a user