mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-53596 Soft wrap for editors
1. Soft wrap appliance point selection algorithm is corrected; 2. Visual position -> (x; y) mapping is corrected in a way to consider 'before soft wrap' sign;
This commit is contained in:
@@ -1124,6 +1124,15 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
|
||||
state.advance();
|
||||
fontType = state.getMergedAttributes().getFontType();
|
||||
}
|
||||
// We need to consider 'before soft wrap drawing'.
|
||||
TextChange softWrap = getSoftWrapModel().getSoftWrap(offset);
|
||||
if (softWrap != null) {
|
||||
column++;
|
||||
x += getSoftWrapModel().getMinDrawingWidthInPixels(SoftWrapDrawingType.BEFORE_SOFT_WRAP_LINE_FEED);
|
||||
if (column >= length) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
FoldRegion region = state.getCurrentFold();
|
||||
|
||||
|
||||
+3
-2
@@ -220,12 +220,13 @@ public class DefaultSoftWrapApplianceManager implements SoftWrapApplianceManager
|
||||
TIntArrayList result = new TIntArrayList();
|
||||
|
||||
// Find offsets where soft wraps should be applied for the logical line in case of no indent usage.
|
||||
int x = myPainter.getMinDrawingWidth(SoftWrapDrawingType.BEFORE_SOFT_WRAP_LINE_FEED);
|
||||
int x = 0;
|
||||
int beforeSoftWrapDrawingWidth = myPainter.getMinDrawingWidth(SoftWrapDrawingType.BEFORE_SOFT_WRAP_LINE_FEED);
|
||||
int prevSoftWrapOffset = start;
|
||||
CharBuffer buffer = CharBuffer.wrap(text);
|
||||
for (int i = start; i < end; i++) {
|
||||
int symbolWidth = myTextRepresentationHelper.textWidth(buffer, i, i + 1, fontType, x);
|
||||
if (x + symbolWidth >= myVisibleAreaWidth) {
|
||||
if (x + symbolWidth + beforeSoftWrapDrawingWidth >= myVisibleAreaWidth) {
|
||||
int offset = calculateSoftWrapOffset(text, i, prevSoftWrapOffset, end);
|
||||
if (offset >= end || offset <= prevSoftWrapOffset) {
|
||||
// There is no way to insert soft wrap.
|
||||
|
||||
Reference in New Issue
Block a user