fzf.vim icon indicating copy to clipboard operation
fzf.vim copied to clipboard

suggestion: refuse to open `:Files` (and other commands) if `'hidden'` is off and window has unsaved changes

Open andmis opened this issue 1 year ago • 2 comments

Checklist

  • [X] I have fzf 0.54.0 or later
  • [X] I have searched through the existing issues

Output of :echo system(fzf#exec() .. ' --version')

n/a

OS

  • [ ] Linux
  • [ ] macOS
  • [ ] Windows
  • [ ] Etc.

Problem / Steps to reproduce

sometimes i enter :Files, spend some time to find the file i want to open, then press enter, only to be greeted with an error, because i run w/ 'hidden' off and happen to have some unsaved changes.

it would be great for :Files to refuse to open at all in this case.

andmis avatar Aug 12 '24 00:08 andmis

Files can open files even in that case when the user presses CTRL-X, CTRL-T, or CTRL-V, so not opening fzf at all is not desirable. If you really must, It is possible to conditionally disable enter key like so.

command! -bang -nargs=? -complete=dir Files
  \ call fzf#vim#files(<q-args>, fzf#vim#with_preview({'options': &modified && !&hidden ? ['--bind=enter:ignore', '--header', 'Enter key disabled'] : []}), <bang>0)

junegunn avatar Aug 16 '24 04:08 junegunn

Let me see whether if it makes sense to make this the default.

junegunn avatar Aug 16 '24 04:08 junegunn