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
Allow tilde forward slash on Windows
citizenmatt committed Oct 27, 2023

Verified

This commit was signed with the committer’s verified signature.
citizenmatt Matt Ellis
commit 116a35a67b0af043d23ba476f33fcf29137e745b
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
@@ -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));