mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
don't commit documents in move left/right action update (IDEA-161071)
This commit is contained in:
+13
@@ -15,11 +15,24 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.editorActions.moveLeftRight;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MoveElementLeftAction extends EditorAction {
|
||||
public MoveElementLeftAction() {
|
||||
super(new MoveElementLeftRightActionHandler(true));
|
||||
setInjectedContext(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeActionPerformedUpdate(@NotNull AnActionEvent e) {
|
||||
Project project = e.getProject();
|
||||
if (project != null) {
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
}
|
||||
super.beforeActionPerformedUpdate(e);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-4
@@ -61,10 +61,9 @@ public class MoveElementLeftRightActionHandler extends EditorWriteActionHandler
|
||||
if (project == null) return false;
|
||||
Document document = editor.getDocument();
|
||||
if (!(document instanceof DocumentEx)) return false;
|
||||
PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(project);
|
||||
psiDocumentManager.commitDocument(document);
|
||||
PsiFile file = psiDocumentManager.getPsiFile(document);
|
||||
if (file == null || !file.isValid()) return false;
|
||||
|
||||
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(document);
|
||||
if (file == null) return false;
|
||||
PsiElement[] elementList = getElementList(file, caret.getSelectionStart(), caret.getSelectionEnd());
|
||||
return elementList != null;
|
||||
}
|
||||
|
||||
+14
@@ -15,11 +15,25 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.editorActions.moveLeftRight;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.editor.actionSystem.EditorAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class MoveElementRightAction extends EditorAction {
|
||||
public MoveElementRightAction() {
|
||||
super(new MoveElementLeftRightActionHandler(false));
|
||||
setInjectedContext(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeActionPerformedUpdate(@NotNull AnActionEvent e) {
|
||||
Project project = e.getProject();
|
||||
if (project != null) {
|
||||
PsiDocumentManager.getInstance(project).commitAllDocuments();
|
||||
}
|
||||
super.beforeActionPerformedUpdate(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user