Closed Astara closed 7 years ago
wait a second. It already detects if the file is already edited in another Vim instance. And in that case it does not delete the swap file. That is the correct solution.
Yes, that is the correct solution, but it also doesn't delete the swap file if there IS no other Vim instance with the file open (and there are no changes).
I'm proposing that:
1) if a file is not open in another window, AND 2) it is not modified,
then there there be a config-option to auto-delete the swap file... does that sound more reasonable (and clear?)...
okay, please check again (and also see the help for how to configure it this way).
Getting this error:
Error detected while processing function recover#ConfirmSwapDiff:
line 28:
E706: Variable type mismatch for: msg
line 32:
E714: List required
0
Swap and on-disk file seem to be identical
Swap File '.dataspec.h.swp' found:
D(i)ff, (O)pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (A)bort, [D]elete:
....
If I try to edit it without "recover.vim" in my .vim folder, I get the expected message:
E325: ATTENTION
Found a swap file by the name ".dataspec.h.swp"
owned by: astara dated: Wed Mar 15 01:38:01 2017
file name: /home/tools/xosview/xosview-1.90/src/dataspec.h
modified: no
user name: astara host name: Ishtar
process ID: 65559 (still running)
While opening file "dataspec.h"
dated: Mon Mar 13 20:18:20 2017
I think I broke it... :-(
sigh... have to go to dentist, so might be slow in getting back for another test...
Oops, should be fixed now.
Better... no error messages now.. In the case of the file unchanged, but open in another window (or by another user), it shows the full warning about it being edited... which is good.
But a few things when no one is editing the file (and its unchanged).;
1) Gvim comes up with a blank screen, and at the bottom it says "Press Enter or type command to continue".
The you press enter, and you see the file, but the "Press Enter or type command to continue" message is still at the bottom.
2) (this may be intentional) the 2nd opening of the file doesn't delete the old swap file, but acts as though you chose "Edit anyway".
If the swap file is same as the original, why keep the old one?
Looking better. :-) Tnx!
1) I don't see that message. I see gvim flashing the swapfileexists dialog and then it opens up. 2) I rather not delete anything by default.
This: is the message I see now, when opening meter.cc a second time.
As for not deleting anything by default -- I won't push too much on that -- if I can do something similar as before and modify script to do so for me. Else .. 2 things 1) maybe you could include a variable that someone would set in .vimrc or .gvimrc like is done for syntax files, like for bash shell... uses .sh syntax, but one can set: let g:is_bash=1
or 2) regarding not deleting... if this is case, we are talking about deleting a "swp" file that isn't in use (right?) and that swap file has no changes compared to the original file, right?
So why would someone want to keep it?
(For me, I don't, which is why I ask why someone would want to keep it?
But if you an think of any reason why someone would not want it deleted, when it contains no difference, and doesn't indicate another user... ...then why not?
? A*a
It would really be a nice enhancement if a value could be set in my .vimrc ... something like let g:Recover_delete_redundant_swaps=1
(or any other easy way to do it... )
If it didn't have the problem of not detecting file already being edited, I'd just hack in Delete as a default in my local copy (not knowing much about vim scripting, I used the 'mod' (posted at end in 'diff -u' (patch) form), but it also deletes the file when someone else is editing it ;-(
(Usually me, but in some forgotten window that's been minimized... ;-))...