mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
MultiCaretCodeInsightAction: commit the document only when the action is invoked (IDEA-160724)
This commit is contained in:
+12
-5
@@ -73,6 +73,15 @@ public abstract class MultiCaretCodeInsightAction extends AnAction {
|
||||
hostEditor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeActionPerformedUpdate(@NotNull AnActionEvent e) {
|
||||
Project project = e.getProject();
|
||||
if (project != null) {
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
}
|
||||
super.beforeActionPerformedUpdate(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
final Presentation presentation = e.getPresentation();
|
||||
@@ -104,16 +113,14 @@ public abstract class MultiCaretCodeInsightAction extends AnAction {
|
||||
private static void iterateOverCarets(@NotNull final Project project,
|
||||
@NotNull final Editor hostEditor,
|
||||
@NotNull final MultiCaretCodeInsightActionHandler handler) {
|
||||
PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
|
||||
final PsiFile psiFile = documentManager.getCachedPsiFile(hostEditor.getDocument());
|
||||
documentManager.commitAllDocuments();
|
||||
PsiFile hostFile = PsiDocumentManager.getInstance(project).getPsiFile(hostEditor.getDocument());
|
||||
|
||||
hostEditor.getCaretModel().runForEachCaret(new CaretAction() {
|
||||
@Override
|
||||
public void perform(Caret caret) {
|
||||
Editor editor = hostEditor;
|
||||
if (psiFile != null) {
|
||||
Caret injectedCaret = InjectedLanguageUtil.getCaretForInjectedLanguageNoCommit(caret, psiFile);
|
||||
if (hostFile != null) {
|
||||
Caret injectedCaret = InjectedLanguageUtil.getCaretForInjectedLanguageNoCommit(caret, hostFile);
|
||||
if (injectedCaret != null) {
|
||||
caret = injectedCaret;
|
||||
editor = caret.getEditor();
|
||||
|
||||
Reference in New Issue
Block a user