mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IJPL-72931 vcs: enable 'Blame' for preview toolwindows in "Find Usages" and "Find in Path"
GitOrigin-RevId: 9561f20b13c05a3745e6c54a32fa42ea32f4ded7
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b429ce5da8
commit
21669bd9b2
@@ -353,7 +353,11 @@ public interface Editor extends UserDataHolder {
|
||||
/** Returns the project to which the editor is related, if any. */
|
||||
@Nullable Project getProject();
|
||||
|
||||
/** Returns the file being edited, if any. */
|
||||
/**
|
||||
* Returns the file being edited, if any. Not necessary matching the {@link #getDocument()}, often <code>null</code>.
|
||||
* <p>
|
||||
* See also {@link com.intellij.openapi.fileEditor.FileDocumentManager#getFile(Document)} as a more reliable alternative.
|
||||
*/
|
||||
default VirtualFile getVirtualFile() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -871,6 +871,7 @@ f:com.intellij.openapi.vcs.actions.VcsAnnotateUtil
|
||||
- s:getBackgroundableLock(com.intellij.openapi.project.Project,com.intellij.openapi.vfs.VirtualFile):com.intellij.openapi.vcs.impl.BackgroundableActionLock
|
||||
- s:getEditorFor(com.intellij.openapi.vfs.VirtualFile,com.intellij.openapi.actionSystem.DataContext):com.intellij.openapi.editor.Editor
|
||||
- s:getEditors(com.intellij.openapi.project.Project,com.intellij.openapi.vfs.VirtualFile):java.util.List
|
||||
- s:isEditorForFile(com.intellij.openapi.editor.Editor,com.intellij.openapi.vfs.VirtualFile):Z
|
||||
f:com.intellij.openapi.vcs.actions.VcsColorsPageFactory
|
||||
- com.intellij.application.options.colors.ColorAndFontPanelFactory
|
||||
- com.intellij.openapi.options.colors.ColorAndFontDescriptorsProvider
|
||||
|
||||
@@ -84,7 +84,7 @@ public final class AnnotateLocalFileAction {
|
||||
}
|
||||
else {
|
||||
Editor editor = e.getData(CommonDataKeys.EDITOR);
|
||||
if (editor != null && !Objects.equals(editor.getVirtualFile(), selectedFile)) {
|
||||
if (editor != null && !VcsAnnotateUtil.isEditorForFile(editor, selectedFile)) {
|
||||
editor = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,9 @@ import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.DataContext;
|
||||
import com.intellij.openapi.actionSystem.PlatformCoreDataKeys;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileEditor.FileEditor;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.fileEditor.TextEditor;
|
||||
@@ -28,7 +30,7 @@ public final class VcsAnnotateUtil {
|
||||
|
||||
public static @Nullable Editor getEditorFor(@NotNull VirtualFile file, @NotNull DataContext dataContext) {
|
||||
Editor editor = dataContext.getData(CommonDataKeys.EDITOR);
|
||||
if (editor != null && file.equals(editor.getVirtualFile())) {
|
||||
if (editor != null && isEditorForFile(editor, file)) {
|
||||
return editor;
|
||||
}
|
||||
|
||||
@@ -43,6 +45,12 @@ public final class VcsAnnotateUtil {
|
||||
.first();
|
||||
}
|
||||
|
||||
public static boolean isEditorForFile(@NotNull Editor editor, @NotNull VirtualFile file) {
|
||||
// Editor.getVirtualFile is not being set for many editors
|
||||
Document document = FileDocumentManager.getInstance().getCachedDocument(file);
|
||||
return editor.getDocument().equals(document);
|
||||
}
|
||||
|
||||
public static @NotNull BackgroundableActionLock getBackgroundableLock(@NotNull Project project, @NotNull VirtualFile file) {
|
||||
return BackgroundableActionLock.getLock(project, VcsBackgroundableActions.ANNOTATE, file);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user