sindrets / diffview.nvim

Single tabpage interface for easily cycling through diffs for all modified files for any git rev.
Other
3.85k stars 105 forks source link

DiffviewOpen throws an error if file already open #289

Closed mikesmithgh closed 1 year ago

mikesmithgh commented 1 year ago

I often open a separate terminal (Kitty on OSX) to run Diffview on a project that I already have open. If files are already open and created a swap file, then DiffviewOpen will throw an error.

Steps to reproduce:

  1. mkdir tempdir && cd tempdir && git init && echo "test" > test.txt
  2. nvim test.txt
  3. In a new terminal, nvim -c ":DiffviewOpen"
  4. Nvim prompts that swap file exits
  5. Type o
  6. Diffview throws an error
    Error executing vim.schedule lua callback: ...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:18: The coroutine failed with this message: ...ack/packer/start/dif
    fview.nvim/lua/diffview/vcs/file.lua:138: Error executing lua: ...ack/packer/start/diffview.nvim/lua/diffview/vcs/file.lua:139: Vim(edit):E325: ATTENTION                 
    stack traceback:                                                                                                                                                          
        [C]: in function 'cmd'                                                                                                                                            
        ...ack/packer/start/diffview.nvim/lua/diffview/vcs/file.lua:139: in function <...ack/packer/start/diffview.nvim/lua/diffview/vcs/file.lua:138>                    
        [C]: in function 'resume'                                                                                                                                         
        ...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:45: in function <...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:44>                      
    stack traceback:                                                                                                                                                          
        [C]: in function 'error'                                                                                                                                          
        ...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:18: in function 'callback_or_next'                                                                    
        ...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:45: in function <...ck/packer/start/plenary.nvim/lua/plenary/async/async.lua:44> 

Workaround

Close open file to remove swap file before running DiffviewOpen or just use it in the same nvim session.

sindrets commented 1 year ago

Given that you:

  1. Use swap files
  2. Know the risk of editing a file with a swap from multiple editor instances
  3. Want to do so anyway

... Have you considered just disabling the swap conflict warning?

In case you didn't know, you can do this by appending A to your 'shortmess':

set shortmess+=A
sindrets commented 1 year ago

Closing due to inactivity from OP.