chrisbra / Recover.vim

A Plugin to show a diff, whenever recovering a buffer
http://www.vim.org/scripts/script.php?script_id=3068
247 stars 25 forks source link

prompt shows only when the swap is dirty? #64

Closed damnskippy closed 5 years ago

damnskippy commented 5 years ago

Is it correct that now the "recover" prompt is shown only when the swap file is dirty? i.e. there are unsaved changes in the main buffer? It used to be that in the past when a file is opened more than once at a time Recover would detect the presence of an (old) swap file and offer to delete the (old) swap file if no differences existed between the two. This was really useful. It offered a convenient way to delete the old swapfile. Particularly useful if/when vim crashes and leaves a swap file behind, etc. It was also useful to know that a given file is open in more than one vim instance..

Now if same file is opened multiple vim instances at the same time, recover doesn't prompt anything to indicate that this is the case (unless the swap file is dirty)? I think this is likely introduced via commits https://github.com/chrisbra/Recover.vim/commit/f545fa8cf2ef26a3989237ad180aba8113e886d3 and specifically https://github.com/chrisbra/Recover.vim/commit/9924586a7f0cd9641f758f0f3c22772b623e3d12

Not sure if Recover knows if a swap file exists but the process (vim) that created the swap file is no longer around, then in that case offer to diff and subsequently to delete the old swap file?

Thanks.

chrisbra commented 5 years ago

That depends on the Configuration. Please read the help.

Am 25.03.2019 um 19:27 schrieb damnskippy notifications@github.com:

Is it correct that now the "recover" prompt is shown only when the swap file is dirty? i.e. there are unsaved changes in the main buffer? It used to be that in the past when a file is opened more than once at a time Recover would detect the presence of an (old) swap file and offer to delete the (old) swap file if no differences existed between the two. This was really useful. It offered a convenient way to delete the old swapfile. Particularly useful if/when vim crashes and leaves a swap file behind, etc. It was also useful to know that a given file is open in more than one vim instance..

Now if same file is opened multiple vim instances at the same time, recover doesn't prompt anything to indicate that this is the case (unless the swap file is dirty)? I think this is likely introduced via commits f545fa8 and specifically 9924586

Not sure if Recover knows if a swap file exists but the process (vim) that created the swap file is no longer around, then in that case offer to diff and subsequently to delete the old swap file?

Thanks.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

damnskippy commented 5 years ago

Thanks, I've been using the default configuration all along i.e. I don't have any of the special knobs enabled. If I checkout 785f130 (as opposed to master) I see the old/original behavior but after that the prompt is not shown unless the swap is dirty. Below is all I'm doing to test this.

$ echo foo > foo.txt
$ gvim foo.txt
$ gvim foo.txt

Maybe this change in behavior is intentional. My vim is about 2 months old - at patch 805.

chrisbra commented 5 years ago

yeah, i think you are correct. The commit 9924586 mentions to only show the confirm message if the swap file has been modified.

damnskippy commented 5 years ago

Thanks. I was just saying that the old behavior was useful and had its merit in its own right, and was suggesting perhaps the change in behavior could be made conditional with a user option. FWIW, with the changes below I could bring back the old behavior via user option g:RecoverPlugin_Prompt_Verbose.

This is just a suggestion and I'll defer to you on incorporating this in (would be great if you can). I'm closing out this issue.

Thanks for this plugin and contributions elsewhere.

diff --git a/autoload/recover.vim b/autoload/recover.vim
index 276f548..b3430e2 100755
--- a/autoload/recover.vim
+++ b/autoload/recover.vim
@@ -193,7 +193,8 @@ fu! recover#ConfirmSwapDiff() "{{{1
     let v:swapchoice = 'd'
     return
   endif
-  if !do_modification_check && !not_modified && (empty(pname) || pname =~? 'vim')
+  let prompt_verbose = get(g:, 'RecoverPlugin_Prompt_Verbose', 0)
+  if prompt_verbose || (!do_modification_check && !not_modified && (empty(pname) || pname =~? 'vim'))
     echo msg
   endif
   call delete(tfile)
@@ -207,9 +208,7 @@ fu! recover#ConfirmSwapDiff() "{{{1
   else
     let info = "Swap File '". v:swapname. "' found: "
   endif
-  if not_modified
-    let p = 3
-  else
+  if prompt_verbose || !not_modified
     call inputsave()
     if has("nvim")
       " Force the msg to be drawn for Neovim, fixes
@@ -218,6 +217,8 @@ fu! recover#ConfirmSwapDiff() "{{{1
     endif
     let p = confirm(info, cmd, (delete ? 7 : 1), 'I')
     call inputrestore()
+  elseif not_modified
+      let p = 3
   endif
   let b:swapname=v:swapname
   if p == 1 || p == 3
chrisbra commented 5 years ago

Thanks for the feedback. Makes sense to make this conditionally. I'll leave it open until I have incorporated your patch. Thanks!

damnskippy commented 5 years ago

Thank you - truly appreciate it!