antoinemadec / coc-fzf

fzf :heart: coc.nvim
388 stars 28 forks source link

Outline doesn't work when buffer name contains colon `:` #103

Closed Frederick888 closed 3 years ago

Frederick888 commented 3 years ago

Environment

Features: +acl +iconv +tui See ":help feature-compile"

system vimrc file: "$VIM/sysinit.vim" fall-back for $VIM: "/usr/local/Cellar/neovim/0.5.0/share/nvim"

Run :checkhealth for more info


# Describe the Bug
9cdffd8 breaks coc-fzf outline in virtual files.

For example, when I'm working on a Java project, I can go to the definition of a class from a library. jdt.ls (the Java language server) decompiles the `.class` file and sometimes download documentations if needed, and present the result in a buffer, of which the buffer name is something like `jdt://contents/spring-webmvc-4.3.8.RELEASE.jar/org.springframework.web.servlet.config.annotation/WebMvcConfigurerAdapter.class?=...`. In this case, trying to show outline leads to the following error:

Error running 'fzf' '--multi' '--expect=ctrl-v,ctrl-x,ctrl-t' '--ansi' '--prompt=Coc Outline> ' '--layout=reverse-list' '--preview-window' 'down:65%:wrap:+//contents/spring-webmvc-4.3.8.RELEASE.jar/org.springframework.web.servlet.config.annotation...=/mav en.scope=/compile=/%3Corg.springframework.web.servlet.config.annotation(WebMvcConfigurerAdapter.class:{-2}' '--bind' '?:toggle-preview' '--delimiter=:' --no-height --border=rounded > /var/folders/k7/yr15b9rs2mb68vyz3_s7_n100000gq/T/nvimlxAA75/5



# Expected Behavior
Outline still works.

I guess this is because `fzf` here needs an actual file for previews to happen? I'm happy if we can simply disable previews in such cases, or of course it'd be even better if we can pipe the buffer contents to fzf to make it work everywhere.
antoinemadec commented 3 years ago

When you say it breaks outline, is it just the preview that is broken, or is the outline not useable anymore ?

Did you check if an issue was already open on fzf.vim ?

Will try to see if we can catch this on coc-fzf side easily. Might need a testcase, will let you know.

Frederick888 commented 3 years ago

In such files outline is not usable any more. It prints the mentioned error message and then nothing shows up.

Actually the generated fzf command looks a bit off. Usually it should be something like fzf --multi --expect=ctrl-v,ctrl-x,ctrl-t --ansi --prompt=Coc Outline> --layout=reverse-list --preview-window down:65%:wrap:+{-2}-5 --preview '/home/frederick/.vim/plugged/fzf.vim/bin/preview.sh' /home/frederick/Programming/Java/bikedriving/src/main/java/com/frederick/bikedriving/BikeDrivingApplication.java:{-2} --bind ?:toggle-preview --delimiter=: --no-height --border=rounded. It appears to me that some special character escaping is not handled correctly somewhere... I'll also dig deeper if I get a chance.

Frederick888 commented 3 years ago

Hmm... actually it's not 'virtual' files that broke it, but : in the buffer name.

I just tried moving a random Python project into /tmp/foo:bar and outline stopped working on all regular files.

Update Another simple example: nvim https://www.google.com/index.html then try opening outline.

totocaca69 commented 3 years ago

@Frederick888 I fixed it by removing the preview for files featuring a colon.

Thanks for reporting this issue 😉

Frederick888 commented 3 years ago

@totocaca69 Is this because fzf uses colon as option delimiter? Any workarounds to make previews work in such cases? 😅

totocaca69 commented 3 years ago

Here is the script that fzf.vim uses for preview: https://github.com/junegunn/fzf.vim/blob/master/bin/preview.sh It relies on the :, there is no way around it 😞

But we could maybe create a temp file without the :. I might try it today, no guarantee though.

totocaca69 commented 3 years ago

@Frederick888 done ! Please update and let me know if this works for you.

Frederick888 commented 3 years ago

@totocaca69 Yup it worked flawlessly! Thanks a ton for working on this :)