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
feat(path): expand ~\ prefix on MS-Windows #28515
base: master
Are you sure you want to change the base?
Conversation
@@ -1872,7 +1873,13 @@ char *fix_fname(const char *fname) | |||
#ifdef UNIX | |||
return FullName_save(fname, true); | |||
#else | |||
if (!vim_isAbsName(fname) | |||
if (*fname == '~' && (fname[1] == '/' || fname[1] == '\\')) { | |||
const char *profile_dir = os_getenv("USERPROFILE"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
os_homedir
Line 502 in 47dbda9
static char *os_homedir(void) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That function is static
, how do I get homedir
out of env.c
?
@@ -1863,7 +1863,8 @@ int vim_FullName(const char *fname, char *buf, size_t len, bool force) | |||
/// the root may have relative paths (like dir/../subdir) or symlinks | |||
/// embedded, or even extra separators (//). This function addresses | |||
/// those possibilities, returning a resolved absolute path. | |||
/// For MS-Windows, this also expands names like "longna~1". | |||
/// For MS-Windows, this also expands names like "longna~1" and | |||
/// replaces "~/" or "~\" prefixes with the user profile directory. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this function not expand ~/
on unix? doesn't seem like the right place to do this then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On unix I believe the shell does this itself.
What problem is this solving? Give a specific use-case, describing the steps exactly. |
So, PowerShell on Windows recently removed the feature where arguments such as What this means is, in PowerShell, when you run a command such as: nvim ~/.ssh/config , what happens is that nvim tries to open |
a9121fa
to
41b7810
Compare
If you don't want to do this that's up to you, I believe this is a harmless enough change because in these cases the user is very unlikely to want to open a file in literal nvim (gi ~/.ssh/config) , instead to get the file I want. |
I don't understand the lint failure, what am I doing wrong there? |
We might want to address this, but need to be sure that
I had heard differently in another issue. Maybe it's configurable? Can you provide a reference (which should have been mentioned from the start, in the PR description) |
So I tried to do this in
There used to be an experimental feature for this in In the unreleased development version of PowerShell, which may not be released for quite a while yet, there is an experimental feature for this, |
I believe it would be better if we address this in neovim, because this PowerShell experimental feature will not be available for a while yet, and when it is it would require enabling it, and if this is done in neovim it would also work in WinPS ( |
I should also mention that the PowerShell completion behavior for tilde paths has also recently changed. Before, when you would type: nvim ~/.ssh/config<TAB> , it would expand to the absolute path, but PowerShell no longer expands tilde paths to absolute paths, it expands them to canonical tilde paths, leading to the behavior in neovim that I described. |
If there is not already an issue tracking this, please consider opening an issue with your notes. |
In fix_fname() for MS-Windows, expand "~\" or "~/" prefixed paths to the USERPROFILE environment variable for the user's profile directory instead of a relative path to a literal "~" directory. Fix neovim#23901 Signed-off-by: Rafael Kitover <[email protected]>
41b7810
to
323fdbf
Compare
Done, the issue you linked was it. |
In fix_fname() for MS-Windows, expand
"~\"
or"~/"
prefixed paths to the USERPROFILE environment variable for the user's profile directory.