mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
diff: update foldings in a single batch operation
This fixes completion popup blinking on typing If we destroy and install foldings in separate operaions, caret's visual position jumps back and forth, triggering popup close
This commit is contained in:
@@ -99,6 +99,7 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
|
||||
@CalledInAwt
|
||||
protected void onDispose() {
|
||||
destroyChangedBlocks();
|
||||
myFoldingModel.destroy();
|
||||
super.onDispose();
|
||||
}
|
||||
|
||||
@@ -225,6 +226,7 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
|
||||
private Runnable apply(@NotNull final CompareData data) {
|
||||
return () -> {
|
||||
myFoldingModel.updateContext(myRequest, getFoldingModelSettings());
|
||||
|
||||
clearDiffPresentation();
|
||||
|
||||
myIsContentsEqual = data.isContentsEqual();
|
||||
@@ -253,6 +255,7 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
|
||||
private Runnable applyNotification(@Nullable final JComponent notification) {
|
||||
return () -> {
|
||||
clearDiffPresentation();
|
||||
myFoldingModel.destroy();
|
||||
if (notification != null) myPanel.addNotification(notification);
|
||||
};
|
||||
}
|
||||
@@ -290,8 +293,6 @@ public class SimpleDiffViewer extends TwosideTextDiffViewer {
|
||||
}
|
||||
myInvalidDiffChanges.clear();
|
||||
|
||||
myFoldingModel.destroy();
|
||||
|
||||
myContentPanel.repaintDivider();
|
||||
myStatusPanel.update();
|
||||
}
|
||||
|
||||
+2
-1
@@ -88,6 +88,7 @@ public abstract class ThreesideTextDiffViewerEx extends ThreesideTextDiffViewer
|
||||
@CalledInAwt
|
||||
protected void onDispose() {
|
||||
destroyChangedBlocks();
|
||||
myFoldingModel.destroy();
|
||||
super.onDispose();
|
||||
}
|
||||
|
||||
@@ -119,6 +120,7 @@ public abstract class ThreesideTextDiffViewerEx extends ThreesideTextDiffViewer
|
||||
protected Runnable applyNotification(@Nullable final JComponent notification) {
|
||||
return () -> {
|
||||
clearDiffPresentation();
|
||||
myFoldingModel.destroy();
|
||||
if (notification != null) myPanel.addNotification(notification);
|
||||
};
|
||||
}
|
||||
@@ -135,7 +137,6 @@ public abstract class ThreesideTextDiffViewerEx extends ThreesideTextDiffViewer
|
||||
|
||||
@CalledInAwt
|
||||
protected void destroyChangedBlocks() {
|
||||
myFoldingModel.destroy();
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -100,12 +100,21 @@ public class FoldingModelSupport {
|
||||
@NotNull final Settings settings) {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
|
||||
if (changedLines == null) return;
|
||||
if (settings.range == -1) return;
|
||||
for (FoldedBlock folding : getFoldedBlocks()) {
|
||||
folding.destroyHighlighter();
|
||||
}
|
||||
|
||||
runBatchOperation(() -> {
|
||||
FoldingBuilder builder = new FoldingBuilder(context, settings);
|
||||
builder.build(changedLines);
|
||||
for (FoldedBlock folding : getFoldedBlocks()) {
|
||||
folding.destroyFolding();
|
||||
}
|
||||
myFoldings.clear();
|
||||
|
||||
|
||||
if (changedLines != null && settings.range != -1) {
|
||||
FoldingBuilder builder = new FoldingBuilder(context, settings);
|
||||
builder.build(changedLines);
|
||||
}
|
||||
});
|
||||
|
||||
updateLineNumbers(true);
|
||||
@@ -244,23 +253,15 @@ public class FoldingModelSupport {
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
for (int i = 0; i < myCount; i++) {
|
||||
destroyFoldings(i);
|
||||
}
|
||||
|
||||
for (FoldedBlock folding : getFoldedBlocks()) {
|
||||
folding.destroyHighlighter();
|
||||
}
|
||||
myFoldings.clear();
|
||||
}
|
||||
|
||||
private void destroyFoldings(final int index) {
|
||||
final FoldingModelEx model = myEditors[index].getFoldingModel();
|
||||
model.runBatchFoldingOperation(() -> {
|
||||
runBatchOperation(() -> {
|
||||
for (FoldedBlock folding : getFoldedBlocks()) {
|
||||
FoldRegion region = folding.getRegion(index);
|
||||
if (region != null) model.removeFoldRegion(region);
|
||||
folding.destroyFolding();
|
||||
}
|
||||
myFoldings.clear();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -615,6 +616,13 @@ public class FoldingModelSupport {
|
||||
}
|
||||
}
|
||||
|
||||
public void destroyFolding() {
|
||||
for (int i = 0; i < myCount; i++) {
|
||||
FoldRegion region = myRegions[i];
|
||||
if (region != null) myEditors[i].getFoldingModel().removeFoldRegion(region);
|
||||
}
|
||||
}
|
||||
|
||||
public void destroyHighlighter() {
|
||||
for (RangeHighlighter highlighter : myHighlighters) {
|
||||
highlighter.dispose();
|
||||
|
||||
Reference in New Issue
Block a user