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

Working with MATLAB folders with special symbols #404

Closed
3 of 9 tasks
sriramkswamy opened this issue Jul 17, 2017 · 3 comments
Closed
3 of 9 tasks

Working with MATLAB folders with special symbols #404

sriramkswamy opened this issue Jul 17, 2017 · 3 comments
Labels

Comments

@sriramkswamy
Copy link

sriramkswamy commented Jul 17, 2017

  • Category
    • Question
    • Bug
    • Suggestion
  • OS
    • Linux
    • macOS
    • Windows
    • Etc.
  • Vim
    • Vim
    • Neovim

I have recently had to work a lot on MATLAB codes and MATLAB follows a very weird structure to construct namespaces and classes. To create namespaces, the folder has to be prefixed by the character +, like +foo, and classes have to be preceded by the character @, like @bar. When I try to use :GFiles to navigate this project (with such special characters in folder names), and access a file such as +foo/@bar/baz.m, I get the following error message.

Vim:E492: Not an editor command: foo/@bar/baz.m

I get the same error when I use :Files or even just :FZF. I'm not sure how to handle this error. I am able to reproduce this with the minimal configuration. To reproduce you need a file with structure +foo/@bar/baz.m under a git controlled repository.

@junegunn junegunn added the bug label Jul 18, 2017
@junegunn
Copy link
Owner

Thanks for the report, it's a bug of vim plugin and is a fairly easy one to fix, except I have to make sure that the fix also works on Windows.

@janlazo Hi, I just realized that we should be using fnameescape in this case ("Escape {string} for use as file name command argument."). However I'm not sure if it properly handles backslashes on Windows, and since you know the platform much better than me, so can you check if it works?

Related: vim/vim#541

diff --git a/plugin/fzf.vim b/plugin/fzf.vim
index 24427be..adb0822 100644
--- a/plugin/fzf.vim
+++ b/plugin/fzf.vim
@@ -149,13 +149,7 @@ function! s:tmux_enabled()
 endfunction
 
 function! s:escape(path)
-  let escaped_chars = '$%#''"'
-
-  if has('unix')
-    let escaped_chars .= ' \'
-  endif
-
-  return escape(a:path, escaped_chars)
+  return fnameescape(a:path)
 endfunction
 
 " Upgrade legacy options

@janlazo
Copy link
Contributor

janlazo commented Jul 18, 2017

\,/,:,*,?,",<,>,| cannot be used for filenames in explorer.exe.
Backslashes are okay so far (no issues with relative paths so far via FZF_DEFAULT_COMMAND).
fnameescape('$PATH') == '$PATH' so execute ':edit' fnameescape('$PATH') fails.
We can keep escape to resolve $ in Windows.

let path = fnameescape(a:path)
return s:is_win ? escape(path, '$') : path

@junegunn
Copy link
Owner

@janlazo Thanks. So that's all we need? Good to know that the solution is simple.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants