Sublime Forum

Revert file - does what it says

#1

This may be a bit pedantic, but in my head I make a distinction between editing a file (adding, modifying or deleting its contents via an edit buffer), and changing the file itself on the storage medium (storing the current edit buffer over the file’s contents, or deleting or renaming the file). The latter operations work on the file (and appropriately can be found under the “File” menu) while the former work on the contents of the file and are generally found under the “Edit” menu.

I’ll also mention that while edits can be undone, generally speaking file operations cannot.

The point of this post is the special case of “Revert.” In ST it is found under the “File” menu, but it does not affect the file itself; one might argue it is in the wrong menu.

Also, it can be undo-ne, just like any other edit command. Functionally, it opens another copy of the file currently stored on disk, selects and copies the contents, and replaces the contents of the current edit buffer with the copied text. In particular, this is not the same as closing the current edit buffer (which asks for confirmation if it had been altered), or closing the current project (which saves the current edit buffer and allows you to pick up right where you left off when it is re-opened), or renaming the current edit buffer and re-opening the original file from the disk (while this is the closest operation to what actually does happen during a revert, it is different in that the edited buffer with a new name will be treated like any other unsaved buffer and ST will offer to save it if you try to delete it or exit without saving it).

And this is why I am bringing this all up: while Revert is just another edit that can be undone like any other, that is not obvious. I could delete everything in my edit buffer and save the results over my original file and nobody would blame ST’s programmer for giving me the power to do that. But an edit function named “revert” that deletes everything I’ve done without warning could cause some serious confusion. That’s what prompted this post: I needed to revert my file but did not understand what actually happened when I did.

Possible responses to this situation include any combination of:

  • Ignore it (I can’t find any other mention of the issue in this forum)
  • Tell the user “You can undo this Revert like any other change”
  • Ask the user “You will lose any unsaved changes unless you save them first with a different name. Are you sure you want to revert to the last time you saved this file?”
  • Move the Revert command to the Edit menu, possibly renaming it to “Revert to saved file on disk”
  • Create a different “Revert” function under the File menu that acts more conventionally by warning the user, closing the current edit buffer and re-opening the file (thereby precluding the subsequent use of Undo)

This last choice would replicate what I think of when I think “revert”: “Delete everything I just did and start over,” rather than “reload the contents of this edit buffer with the contents of the file from the last time I saved it”

BTW, after years of having lost work due to power outages (and my own stupidity) I tend to save my work randomly during edit sessions. This makes “reverting” an uncomfortable prospect since I don’t know which version I’d be reverting to. What I really want is “revert to the last time I opened this file” rather than “revert to the last time I saved this file.” But that’s neither here nor there.

0 Likes