mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
expand ~ in WORKON_HOME (PY-10336)
This commit is contained in:
@@ -416,9 +416,7 @@ public class PathManager {
|
||||
// helpers
|
||||
|
||||
private static String getAbsolutePath(String path) {
|
||||
if (path.startsWith("~/") || path.startsWith("~\\")) {
|
||||
path = getUserHome() + path.substring(1);
|
||||
}
|
||||
path = FileUtil.expandUserHome(path);
|
||||
return new File(path).getAbsolutePath();
|
||||
}
|
||||
|
||||
|
||||
@@ -1213,6 +1213,13 @@ public class FileUtil extends FileUtilRt {
|
||||
return path;
|
||||
}
|
||||
|
||||
public static String expandUserHome(String path) {
|
||||
if (path.startsWith("~/") || path.startsWith("~\\")) {
|
||||
path = SystemProperties.getUserHome() + path.substring(1);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static File[] notNullize(@Nullable File[] files) {
|
||||
return notNullize(files, ArrayUtil.EMPTY_FILE_ARRAY);
|
||||
|
||||
@@ -17,9 +17,9 @@ package com.jetbrains.python.sdk.flavors;
|
||||
|
||||
import com.intellij.ide.DataManager;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
@@ -67,7 +67,7 @@ public class VirtualEnvSdkFlavor extends CPythonSdkFlavor {
|
||||
public static VirtualFile getDefaultLocation() {
|
||||
final String path = System.getenv().get("WORKON_HOME");
|
||||
if (!StringUtil.isEmpty(path)) {
|
||||
return LocalFileSystem.getInstance().findFileByPath(path.replace('\\','/'));
|
||||
return LocalFileSystem.getInstance().findFileByPath(FileUtil.expandUserHome(path).replace('\\','/'));
|
||||
}
|
||||
|
||||
final VirtualFile userHome = LocalFileSystem.getInstance().findFileByPath(SystemProperties.getUserHome().replace('\\','/'));
|
||||
|
||||
Reference in New Issue
Block a user