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

fzf vim plugin prompting when swp file exists but open the file as empty in error #2895

Closed
5 of 10 tasks
Masquue opened this issue Jul 25, 2022 · 4 comments
Closed
5 of 10 tasks

Comments

@Masquue
Copy link

Masquue commented Jul 25, 2022

  • I have read through the manual page (man fzf)
  • I have the latest version of fzf
  • I have searched through the existing issues

Info

  • OS
    • Linux
    • Mac OS X
    • Windows
    • Etc.
  • Shell
    • bash
    • zsh
    • fish

Problem / Steps to reproduce

I'm still experiencing issues similar to #1365 when opening a file whose swp file already exists, but the behavior is different in that there is prompting but after choosing the option, the file is opened as empty and results in error state. :ls gives x flag on that buffer.

I guess the error may come from here:

fzf/plugin/fzf.vim

Lines 306 to 316 in ecc418b

let key = remove(a:lines, 0)
let Cmd = get(a:action, key, 'e')
if type(Cmd) == type(function('call'))
return Cmd(a:lines)
endif
if len(a:lines) > 1
augroup fzf_swap
autocmd SwapExists * let v:swapchoice='o'
\| call s:warn('fzf: E325: swap file exists: '.s:fzf_expand('<afile>'))
augroup END
endif

The action key outputted at first line from fzf has been removed at line 306, but line 311 is still checking if a:lines 's length is greater than 1. Thus when selecting only 1 file, the augroup definition is skipped and prompting is showed to ask user for a swapchoice. However I don't know why after manually giving the choice, the file is opened in error state (maybe because of my other plugins).

Having tried commenting out the greater than 1 check, file can be opened successfully in read only mode.

@junegunn
Copy link
Owner

junegunn commented Aug 3, 2022

Thus when selecting only 1 file, the augroup definition is skipped and prompting is showed to ask user for a swapchoice.

Yes, that's the intended behavior. See c4e5ee6

However I don't know why after manually giving the choice, the file is opened in error state

I can't reproduce the problem.

(maybe because of my other plugins).

Probably. Can you check if you still have the issue with the following minimal vimrc?

vim -Nu <(curl https://gist.githubusercontent.com/junegunn/6936bf79fedd3a079aeb1dd2f3c81ef5/raw)

(https://gist.githubusercontent.com/junegunn/6936bf79fedd3a079aeb1dd2f3c81ef5/raw)

@Masquue
Copy link
Author

Masquue commented Aug 3, 2022

Using that minimal vimrc, it does successfully open a file which has swp file. But there is no SwapExists prompting and the file is not opened in readonly mode. Is that expected?

I tried manually commenting out my other plugins, then fzf behaves as expected by prompting and opening the file in readonly mode. So it is my other plugins that's the problem.

Closing this issue as the "more than 1 file" check is intended behavior.

@Masquue Masquue closed this as completed Aug 3, 2022
@Masquue
Copy link
Author

Masquue commented Aug 3, 2022

It seems the problem is the coc.nvim plugin. Don't really know how it interacts with fzf and causes this bug though.

@Emilv2
Copy link
Contributor

Emilv2 commented May 6, 2023

I have exactly the same issue, it seems to be caused by vim-airline in my case.

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

3 participants