Version 0.9 "use relative paths" fix does not work for Windows ?
-
anonymous
Hello,
I have been annoyed for some type by the statusline displaying full path when opening a file under the working directory with Command-T. I wasn't aware of the fix, so I updated to 1.0b today.
However, my statusline keeps displaying full paths:
- I'm working under Windows
- I 'cd' to my working directory as soon as gvim is started
- The command 'pwd' under gvim correctly shows the working directory
- I invoke :CommandT without parameters
- I open a file in a subdirectory => statusline displays the full path
I tried deleting all command-t related files and reinstall to be sure I was using the fixed version. I also tried removing the extra "/" from controller.rb/relative_path_under_working_directory believing that maybe, Windows and its '\' could interfere.
I'm running out of ideas, please help :)
-
Greg Hurrell
As you can see, it's looking for the Vim pwd followed by a slash. Can you check what your Windows box returns for the following command?
:ruby puts CommandT::VIM::pwd
If it's got backslashes in it then that would explain why the change has no effect on Windows.
-
anonymous
Thank you for this immediate answer :)
Output from the command is a path with '\' as a separator. However, I looked at the commit and tried removing the trailing '/' in relative_path_under_working_directory from my controller.rb but it doesn't seem to the trick.
-
Greg Hurrell
Well, removing it wouldn't be enough, you'd have to replace it with a backslash. Have you tried that?
(I imagine you'll have to specify it as "\\" otherwise it will be treated as an escape character.)
-
anonymous
Yep, I tried :(
I don't no anything about ruby. Am I supposed to run 'ruby extconf.rb' and 'make' after any changes to controller.rb ? Or a vim reload should do the trick ?
-
Greg Hurrell
Just quit and restart Vim. Only changes to the C code would require a
make
. -
anonymous
Is there anyway I could print the value of 'path' and the result of 'path.index([...])' from the function ? That could help us understanding.
-
Greg Hurrell
You can use the
:ruby
command to evaluate the result of any Ruby expression, although in this case simply logging the paths to a file might be the easiest.I don't know where temp files live on Windows but editing the method to read something like the following may work (not tested, just typed into browser):
def relative_path_under_working_directory path File.open('/tmp/command-t.log', 'a') do |f| f.puts "before: #{path}" path = path.index(pwd = "#{VIM::pwd}/") == 0 ? path[pwd.length..-1] : path f.puts " after: #{path}" end path end
Maybe not worth logging the "after" line, seeing as you can see the results right there in the window.
-
anonymous
Yep that's it : 'path' variable is a '/' separated path while #{VIM::pwd} is a '\' separated path...
-
Greg Hurrell
The discrepancy is probably because
path
is coming from Ruby-land (the result of a call toFile.expand_path
) andpwd
is coming from Vim-land (the result of evaluating Vim'sgetcwd()
function).Not really sure what the best way to tackle this is. As an experiment, can you tell me if the following correctly converts the backslash "pwd" into the forwardslash equivalent?
:ruby puts File.expand_path(CommandT::VIM::pwd)
-
anonymous
This command outputs the path with '/' as a separator.
I fixed the issue with :
pwd = File.expand_path("#{VIM::pwd}") + "/" path.index(pwd) == 0 ? path[pwd.length..-1] : path
Thank you very much for your help :)
-
Greg Hurrell
Thanks for the report. I believe this change won't break existing behavior on non-Windows platforms, so I'll test it out here and incorporate it in the next release if it proves to be ok.
-
Greg Hurrell
Ok, I've incorporated the fix and will be pushing out a release (1.0) shortly.
-
jason0x43
I'm using command-t with Ruby 1.9.2 and Vim 7.3 on Windows. I ended up having to add a file expansion to the input path to
relative_path_under_working_directory
to get it to work right:
pwd = File.expand_path(VIM::pwd) + '/' path = File.expand_path(path) path.index(pwd) == 0 ? path[pwd.length..-1] : path
Reply
This topic is now closed.