Undo deletion of note

Use case or problem

As someone who likes to keep his notes database clean and organized, I often delete empty or no longer useful notes (Ctrl+Shift+Del). Often, when I do this too fast, I accidentally delete the wrong note, and immediately hit Ctrl+Z in attempt to recover the file from my Recycle Bin, to no avail.

Proposed solution

Since Ctrl+Z is used for Edit Mode undos, I suggest Ctrl+Shift+Z to undo all file movement / deletion related actions (similar to Mac/Windows file navigation behavior). For example, this feature would quickly remediate the following: dragging and dropping files into wrong folder, deleting the wrong note / folder, perhaps even creating a new note by accident?

Current workaround (optional)

I currently have to go to my recyble bin, look for and recover the said file.

Thanks!

24 Likes

You may want to look into using software revision control like “git”. I believe there is a plug-in called obsidian-git that helps automate this process.

1 Like

I have tried several community plugins (for other purposes) and from my experience those can sometimes be a little buggy.

Just curious if there is sufficient community support to warrant this feature as “default-behavior-worthy” to be included in future releases. Or at least added as a Core Plugin. Thanks for the response.

2 Likes

Use case or problem

Set up: I have Obsidian’s “Deleted files” configured to “Move to system trash”, and env is Mac OSX Catalina with Obsidian 0.9.15.

Use-case: If 1) I accidentally delete a file from within Obsidian (either by right-clicking -> Delete or by keyboard shortcut, and then 2) I press cmd+z or select “Edit -> Undo”, nothing happens.

If I go to the system’s trash and I right click on the deleted note, the usual “Put back” menu option isn’t there and I can’t double-click to open the file and copy-paste the contents because you can’t open files while they’re in OSX’s system trash.

Proposed solution

  • Make Undo and cmd+z actually undo delete file operations if the file still exists.
  • Make files sent to the system’s trash have a “Put back” menu option so that it’s easier to recover them if for some reason you can’t recover them from within Obsidian.

Current workaround (optional)

I have to open the system’s trash and manually move the file to my vault.

10 Likes

@juan I’m glad we are on the same page on this. I now have the deleted files moved to Obsidian trash (.trash folder) option enabled in my settings, just as a safeguard in case I delete something valuable to my (frequently emptied) recycle bin.

Use case or problem
A new problem now arises, as for some reason, “.trash” folder does not show up in the file explorer panel on the left, nor does it show up in Ctrl+O searches.

Proposed solution
Display “.trash” folder in file navigation panel. And make Cmd+Z / Ctrl+Z undo file deletion, similar to my initial post.

5 Likes

I may be a little obtuse (no comments necessary), but why is there an option for sending deleted files to a “.Trash” if there is no way to access the folder by the User? Or maybe the question should be…Why can I not Recover a deleted file when selecting the UI option “Move to Obsidian trash”?

5 Likes

I am with you on this as well. The UI is not great.

But the current stop-gap solution at least keeps my accidentally deleted notes “safe”, where I can retrieve it manually via file browser if I ever needed to.

I think all we need is a secondary option to have deleted files moved to a non-hidden folder- ‘Trash’, ‘Trash_Obsidian’, etc.

(or folder name customizable by user.)

3 Likes

I find a third-party solution for that:
you can use google drive to sync your Vault Folder , then when you Try to delete any files in your vault it’s automatically go to google drive trash and you can restore theme easily .

1 Like

Thanks Issam. I prefer to not add an external dependency like that because it introduces a host of sync issues. For now I’m relying on both Obsidian Sync and a .git repo within the vault. It’s not a great experience and I’m still hit by this issue (yesterday for example), but I can manage until we have undo delete file.

2 Likes

This seems like a pretty obvious and basic feature and I wonder why it isn’t there yet?
A simple app like Notes (Mac) allows us to recover a deleted note.
It’s the kind of workflow that any user would expect from the Undo.

Also, I just noticed that if we use Undo after renaming a note, that won’t undo the renaming of the note (which it should), but it just undoes whatever editing we did on the note itself, which is weird as well.

Please add / fix these things. It shouldn’t be expected that user re-learns something that is common in other apps, as well as having to find workarounds for something that should be native.

2 Likes

This link has the technical answer for why “moving a file to ~/.Trash doesn’t give macOS the right metadata to ‘Put Back’ the file from Finder”

It looks like Obsidian, (or possibly a plugin) would need to also edit ~/.Trash/.DS_Store – but I’m unsure if this is supported for third-party apps…

I think it should work akin to Apple Notes, where you can undo deletion with CMD + Z.

It should work at least when deleted notes go to the .trash directory.

2 Likes

Third party apps can and should be able to use trash the same way finder does. There are three ways to put items in trash in mac:

  1. put it in a folder used for Trash by OS - this was once ~/.Trash, but this folder doesn’t exist since a few macOS versions ago … not sure where it is now or if its advisable to use even
  2. use main system API for this - documented, works, but no put back option
  3. use Finder’s own API - documented, works and has Put Back option

Its quite feasible and even correct macOS app development to use option 3!

2 Likes

I’m bumping this: I’m sorry, but this is not intuitive.

  1. There should be a command: “Undo Move to Trash”, which move back the most recently deleted note to it’s original location.

  2. There should be an Undo History chain of X amount of notes (preferably 100) so that trashing several notes in a row will place them back in their last location in reverse. The use case for this is if you accidently delete a note and then delete additional notes: it’s sometimes faster to just undo the chain of deletions to reach back to the note you want to recover, and then re-delete all of the following. Instead of finding the .trash-folder in the file handler, finding the original location and then manually move back the note.

This is how every note taking app I’ve ever used works, it’s how all major file handlers, macro softwares, IDEs, etc work.

The file handling in Obsidian needs an overhaul to correspond to how files are handled in a normal way. Not a “smarter” way, or whatever someone thought of.

2 Likes