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

Soft kill terminal buffer #539

Open
3 tasks done
ghost opened this issue Dec 4, 2017 · 12 comments
Open
3 tasks done

Soft kill terminal buffer #539

ghost opened this issue Dec 4, 2017 · 12 comments

Comments

@ghost
Copy link

ghost commented Dec 4, 2017

  • Category
    • Question
  • OS
    • Windows
  • Vim
    • Vim

fzf 0.17.1, lastest fzf.vim, gvim8 1-1358, windows 10, +terminal
Video demo.
Minimal vimrc:

command! -bang -nargs=* Find
  \ call fzf#vim#grep(
  \   'rg --column --line-number --no-heading --color=always '.shellescape(<q-args>), 1,
  \   <bang>0 ? fzf#vim#with_preview('up:60%')
  \           : fzf#vim#with_preview('right:50%:hidden', '?'),
  \   <bang>0)

nnoremap <C-c> :bdelete<CR>
nnoremap \ :Find<SPACE>

Produce steps:

  • Issue this command in cmd under home directory (i.e: C:\Users\USERNAME):
    gvim.exe --cmd "set nocp | set rtp+=~/vimfiles/pack/plugins/start/fzf | runtime! plugin/fzf.vim"
  • Type :FZF, try to kill terminal buffer with <C-c> --> reuslt buffer killed.
  • Open gvim, open an arbitrary file, try to find a pattern with :Find command (i.e :Find abc). After type :Find abc command, try to kill terminal buffer --> result buffer can't be killed.

So the expected result is that terminal buffer can be killed using <C-c>

@junegunn
Copy link
Owner

junegunn commented Dec 4, 2017

You are probably running into this: BurntSushi/ripgrep#200
AFAIK, It's fixed on *nix systems, but not on Windows.

@ghost
Copy link
Author

ghost commented Dec 4, 2017

I can't find a way to reproduce this issue just using rg.
Test with only 'rg ' give same result, I haven't tested with Ag, grep.

@junegunn
Copy link
Owner

junegunn commented Dec 4, 2017

I missed the screencast you posted above, and it's clear that it's not related to the issue.

@junegunn
Copy link
Owner

junegunn commented Dec 4, 2017

Have you tried googling "terminate batch job"?

@ghost
Copy link
Author

ghost commented Dec 4, 2017

@junegunn : Somehow it's in process of a bat file, terminate it will cause that message. Did fzf wrap rg command in bat file?

@junegunn
Copy link
Owner

junegunn commented Dec 4, 2017

Yes, we always do that.

https://github.com/junegunn/fzf/blob/338a73d76426c0b1be2c792d0082575b46fd1444/plugin/fzf.vim#L692-L693

Does the prompt only appear with fzf#vim#grep? What about other commands?

@ghost
Copy link
Author

ghost commented Dec 4, 2017

Can you name a command that does the same like fzf#vim#grep? We must be able to interfere while it's processing (does temp batfile).

@janlazo
Copy link
Contributor

janlazo commented Dec 5, 2017

I can't reproduce the problem (fzf#vim#grep works) but I have a different setup using the same minimal vimrc (because I don't use packpath). If you passed double quotes to Find, that's a different issue entirely.

>rg --version
ripgrep 0.7.1
-AVX -SIMD
gvim.exe -u minimal_vimrc.vim --cmd "set nocp | set rtp+=~/.fzf rtp+=~/vimfiles/bundle/fzf.vim | runtime! plugin/fzf.vim"

@ghost
Copy link
Author

ghost commented Dec 5, 2017

If you passed double quotes to Find, that's a different issue entirely.

Can you give more details about where to pass double quotes.
Did you mean use double quotes in this 'rg --column --line-number --no-heading --color=always ' instead of single quote?
I use the same rg --version as you.
What do you mean by packpath? Plugin manager can make different?

@janlazo
Copy link
Contributor

janlazo commented Dec 5, 2017

fzf runs the command in a batchfile regardless of the user's shell so single-quote escaping won't work.
double-quote escaping is tricky because there is additional escaping required for cmd.exe (or batchfile) on top of the standard argv escaping in Windows. This standard argv escaping is prepending all double-quotes and backslashes with a backslash and wrapping the argument in double-quotes. shellescape doesn't do this so it should not be used to escape arguments for external programs in Windows. Also, if you use shellslash, then shellescape changes behaviour and makes it completely useless on cmd.exe.

On top of that, the right way to call cmd.exe to minimize edge cases with double quote is cmd.exe /s/c "rg arg1 arg2 arg3 ..." which can be done with Vim. Problem is other plugins (ex. vim-fugitive) rely on the shell defaults so, for interoperability with existing plugins, the user shouldn't change the shell defaults.

What do you mean by packpath? Plugin manager can make different?

Check :h packpath.
I mentioned it because my fzf packages are not in packpath so I had to set rtp with different values.
It shouldn't matter if you use -u minimal_vimrc such that Vim ignores your default vimrc, %USERPROFILE%\vimfiles\vimrc.

@ghost
Copy link
Author

ghost commented Dec 6, 2017

Thanks, but I don't understand much. Can you create a PR or make some changes in files that need to fix this issue so that users can use in their own with risk of interfere with other plugins?

@janlazo
Copy link
Contributor

janlazo commented Dec 6, 2017

The documentation and rationale for the Windows-specific escaping (and fzf#shellescape) is in the main fzf repo. fzf#shellescape is used in Vim plugin of fzf and fzf.vim, mainly to escape arguments for fzf binary, and the same code is used in vim-plug.

I could create PRs to update documentation on all three repos but this is not a high-priority for me right now.

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

No branches or pull requests

2 participants