mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
preserve consistency of EditorSizeManager state when editor is modified while it's hidden
This commit is contained in:
@@ -754,6 +754,10 @@ public class SoftWrapModelImpl implements SoftWrapModelEx, PrioritizedInternalDo
|
||||
return dumpState();
|
||||
}
|
||||
|
||||
public boolean isDirty() {
|
||||
return myDirty;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines generic interface for the command that may be proceeded in both <code>'soft wraps aware'</code> and
|
||||
* <code>'soft wraps unaware'</code> modes.
|
||||
|
||||
+15
@@ -70,6 +70,10 @@ class EditorSizeManager implements PrioritizedDocumentListener, Disposable, Fold
|
||||
private int myFoldingChangeStartOffset = Integer.MAX_VALUE;
|
||||
private int myFoldingChangeEndOffset = Integer.MIN_VALUE;
|
||||
|
||||
private boolean myDirty; // true if we cannot calculate preferred size now because soft wrap model was invalidated after editor
|
||||
// became hidden. myLineWidths contents is irrelevant in such a state. Previously calculated preferred size
|
||||
// is kept until soft wraps will be recalculated and size calculations will become possible
|
||||
|
||||
private final List<TextRange> myDeferredRanges = new ArrayList<TextRange>();
|
||||
|
||||
private final SoftWrapAwareDocumentParsingListenerAdapter mySoftWrapChangeListener = new SoftWrapAwareDocumentParsingListenerAdapter() {
|
||||
@@ -179,6 +183,7 @@ class EditorSizeManager implements PrioritizedDocumentListener, Disposable, Fold
|
||||
private int getPreferredWidth() {
|
||||
if (myWidthInPixels < 0) {
|
||||
assert !myDocument.isInBulkUpdate();
|
||||
assert !myDirty;
|
||||
myWidthInPixels = calculatePreferredWidth();
|
||||
}
|
||||
validateMaxLineWithExtension();
|
||||
@@ -273,6 +278,11 @@ class EditorSizeManager implements PrioritizedDocumentListener, Disposable, Fold
|
||||
}
|
||||
|
||||
private void doInvalidateRange(int startOffset, int endOffset) {
|
||||
if (myDirty) return;
|
||||
if (myEditor.getSoftWrapModel().isDirty()) {
|
||||
myDirty = true;
|
||||
return;
|
||||
}
|
||||
myWidthInPixels = -1;
|
||||
int startVisualLine = myView.offsetToVisualLine(startOffset, false);
|
||||
int endVisualLine = myView.offsetToVisualLine(endOffset, true);
|
||||
@@ -309,6 +319,11 @@ class EditorSizeManager implements PrioritizedDocumentListener, Disposable, Fold
|
||||
}
|
||||
|
||||
private void onTextLayoutPerformed(int startOffset, int endOffset) {
|
||||
if (myDirty) return;
|
||||
if (myEditor.getSoftWrapModel().isDirty()) {
|
||||
myDirty = true;
|
||||
return;
|
||||
}
|
||||
boolean purePaintingMode = myEditor.isPurePaintingMode();
|
||||
boolean foldingEnabled = myEditor.getFoldingModel().isFoldingEnabled();
|
||||
myEditor.setPurePaintingMode(false);
|
||||
|
||||
Reference in New Issue
Block a user