[go: up one dir, main page]

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

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

Open
2 of 6 tasks
andmis opened this issue Aug 12, 2024 · 2 comments
Labels

Comments

@andmis
Copy link
andmis commented Aug 12, 2024

Checklist

  • I have fzf 0.54.0 or later
  • 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.

@junegunn
Copy link
Owner

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
Copy link
Owner

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

@junegunn junegunn reopened this Aug 16, 2024
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

2 participants