mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
ChangeModifierIntention: alternative way to fix the flicker using editor dumb mode (IDEA-CR-48063)
GitOrigin-RevId: 697258ee2992e14e8cc4be75aa2733ede54f5a13
This commit is contained in:
committed by
intellij-monorepo-bot
parent
90c6f0b17d
commit
965250a97d
+20
-10
@@ -16,6 +16,7 @@ import com.intellij.openapi.editor.RangeMarker;
|
||||
import com.intellij.openapi.editor.colors.EditorColors;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.colors.EditorFontType;
|
||||
import com.intellij.openapi.editor.impl.EditorImpl;
|
||||
import com.intellij.openapi.editor.markup.HighlighterLayer;
|
||||
import com.intellij.openapi.editor.markup.HighlighterTargetArea;
|
||||
import com.intellij.openapi.editor.markup.RangeHighlighter;
|
||||
@@ -245,16 +246,25 @@ public class ChangeModifierIntention extends BaseElementAtCaretIntentionAction {
|
||||
})
|
||||
.setNamerForFiltering(AccessModifier::toString)
|
||||
.setItemChosenCallback(t -> {
|
||||
updater.undoChange(false);
|
||||
PsiDocumentManager.getInstance(project).commitDocument(document);
|
||||
updater.setModifier(t);
|
||||
// do not commit document now: checkForConflicts should have original content
|
||||
// while the editor should display the updated content to prevent flicker
|
||||
PsiMember m = memberPointer.getElement();
|
||||
if (m == null) return;
|
||||
PsiModifierList modifierList = m.getModifierList();
|
||||
if (modifierList == null) return;
|
||||
final MultiMap<PsiElement, String> conflicts = checkForConflicts(m, t);
|
||||
if (editor instanceof EditorImpl) {
|
||||
((EditorImpl)editor).startDumb();
|
||||
}
|
||||
MultiMap<PsiElement, String> conflicts;
|
||||
PsiModifierList modifierList;
|
||||
try {
|
||||
updater.undoChange(false);
|
||||
PsiDocumentManager.getInstance(project).commitDocument(document);
|
||||
PsiMember m = memberPointer.getElement();
|
||||
if (m == null) return;
|
||||
modifierList = m.getModifierList();
|
||||
if (modifierList == null) return;
|
||||
conflicts = checkForConflicts(m, t);
|
||||
}
|
||||
finally {
|
||||
if (editor instanceof EditorImpl) {
|
||||
((EditorImpl)editor).stopDumbLater();
|
||||
}
|
||||
}
|
||||
if (conflicts == null) {
|
||||
//canceled by user
|
||||
FinishMarkAction.finish(project, editor, markAction);
|
||||
|
||||
Reference in New Issue
Block a user