mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-180365 Undo in editor does not scroll to changed position
Fix a case with making a change in a diff pane, then performing undo in main editor. In this case comparing classes of editors doesn't work: we have PsiAwareTextEditorProvider.PsiAwareEditorWrapper in the diff pane and PsiAwareTextEditorImpl in the main editor.
This commit is contained in:
@@ -3,23 +3,26 @@ package com.intellij.openapi.command.impl;
|
||||
|
||||
import com.intellij.openapi.fileEditor.FileEditor;
|
||||
import com.intellij.openapi.fileEditor.FileEditorState;
|
||||
import com.intellij.openapi.fileEditor.FileEditorStateLevel;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
class EditorAndState {
|
||||
private final FileEditorState myState;
|
||||
private final Class<? extends FileEditor> myEditorClass;
|
||||
private final VirtualFile myVirtualFile;
|
||||
|
||||
public EditorAndState(FileEditor editor, FileEditorState state) {
|
||||
myEditorClass = editor.getClass();
|
||||
myVirtualFile = editor.getFile();
|
||||
myState = state;
|
||||
}
|
||||
|
||||
public boolean canBeAppliedTo(FileEditor editor) {
|
||||
return editor.getClass() == myEditorClass && Objects.equals(myVirtualFile, editor.getFile());
|
||||
if (editor == null) return false;
|
||||
if (!Objects.equals(myVirtualFile, editor.getFile())) return false;
|
||||
if (myState == null) return false;
|
||||
FileEditorState currentState = editor.getState(FileEditorStateLevel.UNDO);
|
||||
return myState.getClass() == currentState.getClass();
|
||||
}
|
||||
|
||||
public FileEditorState getState() {
|
||||
|
||||
Reference in New Issue
Block a user