bogado / file-line

Plugin for vim to enabling opening a file in a given line
http://www.vim.org/scripts/script.php?script_id=2184
299 stars 61 forks source link

Breaks shell redirection and pipes #82

Open ben-cohen-xs opened 1 year ago

ben-cohen-xs commented 1 year ago

The file-line plugin breaks shell redirection: the command below should start vim with a buffer containing its manpage, but instead vim shows an empty buffer with a name like "/proc/65432/fd/63".

vim <(man vim)

The plugin breaks it because it tries to re-read the buffer, which is not possible from a pipe. You can fix the example above like this, though it would be better to do a more general check for pipes (and other special files) because they can also only be read once.

90c90
< if match(expand("%:p"), "^/proc/.*/fd/.*$") < 0 && match(expand("%:p"), "^/dev/fd/.*$") < 0 && !isdirectory(expand("%:p"))
---
> if !isdirectory(expand("%:p"))
xim commented 1 year ago

We could just add a test for !filereadable(expand("%")) so startup isn't called if there's already something readable there.

ben-cohen-xs commented 1 year ago

Yes, this works for me and is neater than the change in my previous comment:

if !filereadable(expand("%:p")) && !isdirectory(expand("%:p"))
kaddkaka commented 1 year ago

Any progress on this issue?