mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-191807 Cannot paste file into Scratches
This commit is contained in:
@@ -14,6 +14,7 @@ import com.intellij.ide.util.treeView.AbstractTreeNode;
|
||||
import com.intellij.ide.util.treeView.AbstractTreeUi;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.actionSystem.LangDataKeys;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.fileTypes.LanguageFileType;
|
||||
@@ -191,6 +192,14 @@ public class ScratchProjectViewPane extends ProjectViewPane {
|
||||
@Nullable
|
||||
@Override
|
||||
public Object getData(@NotNull Collection<AbstractTreeNode> selected, String dataName) {
|
||||
if (LangDataKeys.PASTE_TARGET_PSI_ELEMENT.is(dataName)) {
|
||||
AbstractTreeNode single = JBIterable.from(selected).single();
|
||||
if (single instanceof MyRootNode) {
|
||||
VirtualFile file = ((MyRootNode)single).getVirtualFile();
|
||||
Project project = single.getProject();
|
||||
return file == null || project == null ? null : PsiManager.getInstance(project).findDirectory(file);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
+5
-3
@@ -7,7 +7,6 @@ import com.intellij.ide.scratch.ScratchFileService;
|
||||
import com.intellij.ide.util.EditorHelper;
|
||||
import com.intellij.ide.util.PlatformPackageUtil;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.Result;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -61,7 +60,10 @@ public class CopyFilesOrDirectoriesHandler extends CopyHandlerDelegateBase {
|
||||
@Override
|
||||
public void doCopy(final PsiElement[] elements, PsiDirectory defaultTargetDirectory) {
|
||||
if (defaultTargetDirectory == null) {
|
||||
defaultTargetDirectory = getCommonParentDirectory(elements);
|
||||
PsiDirectory commonParent = getCommonParentDirectory(elements);
|
||||
if (commonParent != null && !ScratchFileService.isInScratchRoot(commonParent.getVirtualFile())) {
|
||||
defaultTargetDirectory = commonParent;
|
||||
}
|
||||
}
|
||||
Project project = defaultTargetDirectory != null ? defaultTargetDirectory.getProject() : elements [0].getProject();
|
||||
if (defaultTargetDirectory != null) {
|
||||
@@ -76,7 +78,7 @@ public class CopyFilesOrDirectoriesHandler extends CopyHandlerDelegateBase {
|
||||
|
||||
@Nullable
|
||||
private static PsiDirectory tryNotNullizeDirectory(@NotNull Project project, @Nullable PsiDirectory defaultTargetDirectory) {
|
||||
if (defaultTargetDirectory == null || ScratchFileService.isInScratchRoot(defaultTargetDirectory.getVirtualFile())) {
|
||||
if (defaultTargetDirectory == null) {
|
||||
VirtualFile root = ArrayUtil.getFirstElement(ProjectRootManager.getInstance(project).getContentRoots());
|
||||
if (root == null) root = project.getBaseDir();
|
||||
if (root == null) root = VfsUtil.getUserHomeDir();
|
||||
|
||||
Reference in New Issue
Block a user