Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ~/ on Windows #734

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/main/java/com/maddyhome/idea/vim/group/FileGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,17 @@ public boolean openFile(@NotNull String filename, @NotNull ExecutionContext cont

@Nullable VirtualFile findFile(@NotNull String filename, @NotNull Project project) {
VirtualFile found;
if (filename.length() > 2 && filename.charAt(0) == '~' && filename.charAt(1) == File.separatorChar) {
String homefile = filename.substring(2);
// Vim supports both ~/ and ~\ (tested on Mac and Windows). On Windows, it supports forward- and back-slashes, but
// it only supports forward slash on Unix (tested on Mac)
// VFS works with both directory separators (tested on Mac and Windows)
if (filename.startsWith("~/") || filename.startsWith("~\\")) {
String relativePath = filename.substring(2);
String dir = System.getProperty("user.home");
if (logger.isDebugEnabled()) {
logger.debug("home dir file");
logger.debug("looking for " + homefile + " in " + dir);
logger.debug("looking for " + relativePath + " in " + dir);
}
found = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(dir, homefile));
found = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(dir, relativePath));
}
else {
found = LocalFileSystem.getInstance().findFileByIoFile(new File(filename));
Expand Down
Loading