prompt-toolkit / pyvim

Pure Python Vim clone.
BSD 3-Clause "New" or "Revised" License
2.52k stars 161 forks source link

Relative paths do not resolve ("~/" or "$HOME") #79

Closed jcmdln closed 8 years ago

jcmdln commented 8 years ago

When opening a file using :e it appears that relative paths do not resolve at all, and will open a new blank file rather than the intended target.

:e ~/Projects/example/example.conf :e $HOME/Projects/example/example.conf

Assuming that the file in this example existed, it would instead open an empty file with the same path being displayed. If I open pyvim in my user directory ($HOME) then I can traverse the paths normally, which is the workaround I've been using for the moment.

I suppose it's not too much trouble to type /home/user/ but it would be nice if relative paths would also work.

therealfakemoot commented 8 years ago

You can use os.path.abspath(os.path.expanduser(filename)) for evaluating the ~ (it will work for ~username as well as plain ~). Intelligently parsing out env vars before/after expanding ~ is going to be tougher to decide on but it's a start.

jonathanslenders commented 8 years ago

Thanks for reporting! This commit should fix it: https://github.com/jonathanslenders/pyvim/commit/fb0f6956e6b8f8620c2fd3b31bef9697d59fd21c

therealfakemoot commented 8 years ago

Installed fresh from master, confirmed working with PyPy 5.0.1. Thanks!

jcmdln commented 8 years ago

@jonathanslenders That was quick! Looks like that has solved the issue of using ~/ when using long paths, great suggestion @therealfakemoot!

jcmdln commented 8 years ago

Closing for now