qpkorr / vim-renamer

Git repo for http://www.vim.org/scripts/script.php?script_id=1721
MIT License
82 stars 11 forks source link

deleting a file undoes all unsaved changes #15

Open ckat3 opened 4 years ago

ckat3 commented 4 years ago

deleting a file will undo all other changes to the buffer. you can just press u to get them back, but it's a tiny bit annoying. (tested on windows 10.)

ckat3 commented 4 years ago

oh my – turns out that by pressing u to recover the unsaved renamings (and thus seemingly "restoring" the deleted file) i added a ghost entry to the list, so that the plugin got all indexes mixed up and gave files the name of those that came immediately before on the list, etc.

i'm thinking deletion could be scheduled for after running :Ren?

qpkorr commented 4 years ago

Oops - sorry about that :-| Hope it wasn't tooo much of a hassle to restore your original files. Yes, deleting was kind of an afterthought I suppose - and I'll be honest, when I read your first message I thought "What? really? just using u worked to get things back? didn't expect that" - but your subsequent message is far more what I would have expected - since names can be changed to anything, the only common reference for a file is it's line number, so if you add or remove lines from the buffer, as you did by pressing u, confusion results.

I'll have to think about your idea of scheduling deletion - another option would be to disable deletion if the buffer is modified I guess, with an explanatory message. Maybe deletion shouldn't be possible at all since it's not the primary purpose of the plugin (and the command name "Rename" doesn't really imply that deletion will be done as well). I'm inclining towards disabling deletion if the buffer is modified, to keep things simple...

qpkorr commented 4 years ago

hmmm - though the nomodified flag seems to be set on the buffer even if one has modified it... damn, was hoping I could use a simple vim flag to detect mods...