Post

Undo and Redo

Undo and Redo

What is Undo and Redo?

Full undo/redo support for all destructive operations with complete history tracking. Never lose work again - every important operation can be reversed.

Quick Start

Undo last operation:

1
2
Press: Cmd+Alt+Z (or Ctrl+Alt+Z on Windows/Linux)
Command: Noted: Undo

Redo last undone operation:

1
2
Press: Cmd+Shift+Alt+Z (or Ctrl+Shift+Alt+Z on Windows/Linux)
Command: Noted: Redo

Supported Operations

The undo system tracks these destructive operations:

File Operations

  • Delete Note: Restore deleted files with full content
  • Rename Note: Revert name changes
  • Move Note: Return notes to original folders

Bulk Operations

  • Bulk Delete: Restore multiple deleted notes
  • Bulk Move: Revert multiple moved notes
  • Bulk Archive: Unarchive multiple notes

Archive Operations

  • Archive Note: Restore archived notes
  • Bulk Archive: Restore multiple archived notes

How It Works

Operation Tracking

When you perform a destructive operation:

  1. Before: System captures current state
    • File paths
    • File contents
    • Metadata (timestamps, etc.)
  2. During: Operation executes
    • Files moved/deleted/renamed
    • Links updated
  3. After: Operation saved to history
    • Can be undone later
    • Can be redone if undone

History Storage

Undo history is stored:

  • In memory during session
  • Persists across VS Code restarts
  • Includes complete file content
  • Maintains chronological order

Undo Operations

Single Undo

Undo the most recent operation:

1
Command: Noted: Undo

Example:

1
2
You: Delete "meeting-notes.md"
Undo: Restores "meeting-notes.md" with all content

Multiple Undos

Undo multiple operations in sequence:

1
2
3
4
Undo #1: Restores most recent operation
Undo #2: Restores previous operation
Undo #3: Restores operation before that
...

Each undo goes back one step in history.

What Gets Restored

For Delete:

  • File is recreated
  • Original content restored
  • Original location restored
  • File metadata preserved

For Rename:

  • Old file name restored
  • All links updated back
  • No content changes

For Move:

  • File moved back to original folder
  • Folder structure maintained
  • Links remain intact

For Bulk Operations:

  • All affected files restored
  • Each file’s content and location
  • Batch operation reversed

Redo Operations

Single Redo

Redo the most recently undone operation:

1
Command: Noted: Redo

Example:

1
2
3
You: Delete "bug-notes.md"
Undo: Restores "bug-notes.md"
Redo: Deletes "bug-notes.md" again

Multiple Redos

Redo multiple undone operations:

1
2
3
4
Redo #1: Re-applies most recent undo
Redo #2: Re-applies previous undo
Redo #3: Re-applies undo before that
...

Redo Invalidation

New operations clear the redo stack:

1
2
3
Delete "A"
Undo → "A" restored
Delete "B" → Redo stack cleared (can't redo delete A anymore)

This prevents conflicting states.

Undo History

Viewing History

See all tracked operations:

1
Command: Noted: Show Undo History

Example Output:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Undo History (5 operations):

1. Bulk Delete (3 files)
   Time: 2024-10-23 2:45 PM
   Files:
   - 2024-10-01.md
   - 2024-10-02.md
   - meeting-notes.md

2. Move Note
   Time: 2024-10-23 2:30 PM
   File: project-plan.md
   From: Projects/Alpha/
   To: Archive/

3. Rename Note
   Time: 2024-10-23 2:15 PM
   From: bug-fix.md
   To: feature-auth.md

4. Delete Note
   Time: 2024-10-23 1:00 PM
   File: old-notes.md

5. Archive Note
   Time: 2024-10-23 12:30 PM
   File: completed-task.md

History Details

For each operation, see:

  • Operation type
  • Timestamp
  • Affected files
  • Source/destination (for moves)
  • Old/new names (for renames)

History Limits

Default behavior:

  • No hard limit on history size
  • Persists across sessions
  • Can be cleared manually

Clear History

Remove all undo history:

1
Command: Noted: Clear Undo History

Warning Dialog:

1
2
3
4
5
6
Clear all undo history?

This will permanently remove all tracked operations.
You won't be able to undo previous actions.

[Cancel] [Clear History]

When to clear:

  • Free up memory
  • After major reorganization
  • When history is too large

Use Cases

Accidental Deletion

Deleted the wrong file:

1
2
3
4
1. Oh no! Deleted "important-notes.md"
2. Command: Noted: Undo
3. File restored with all content
4. Crisis averted!

Bulk Operation Mistake

Bulk deleted too many files:

1
2
3
4
5
1. Selected and deleted 50 notes
2. Realized you wanted to keep 10 of them
3. Command: Noted: Undo
4. All 50 restored
5. Manually delete only the 40 you don't want

Move Regret

Moved note to wrong folder:

1
2
3
4
5
1. Moved "project.md" to "Archive/"
2. Actually needed it in "Projects/Alpha/"
3. Command: Noted: Undo
4. Back to original location
5. Move it correctly this time

Rename Experiment

Try different names:

1
2
3
4
5
6
7
1. Rename to "new-name.md"
2. Don't like it
3. Undo
4. Try "better-name.md"
5. Still not right
6. Undo
7. Keep original name

Archive Exploration

Experiment with archiving:

1
2
3
4
5
1. Bulk archive 20 old notes
2. Review what's left
3. Decide you want some back
4. Undo
5. Selectively archive subset

Best Practices

  1. Undo Immediately: If you make a mistake, undo right away
  2. Check History: Review undo history before major operations
  3. Don’t Clear Hastily: Keep history unless memory is a concern
  4. Use Confirmations: Don’t rely solely on undo - read confirmation dialogs
  5. Undo vs. Redo: Know which direction you’re going

Tips & Tricks

Undo Shortcuts

Assign custom keyboard shortcuts for faster access:

1
2
3
4
File > Preferences > Keyboard Shortcuts

Noted: Undo → Cmd+Z (or Ctrl+Z)
Noted: Redo → Cmd+Shift+Z (or Ctrl+Shift+Z)

Note: These might conflict with editor undo/redo, so choose unique shortcuts.

Undo Chain

Create undo “save points”:

1
2
3
4
1. Do batch of operations
2. Check result
3. If wrong, undo all
4. If right, continue

History as Audit Log

Use undo history to track what you did:

1
2
3
4
5
6
Command: Noted: Show Undo History

Review:
- What files were deleted
- When moves happened
- Rename history

Useful for remembering recent actions!

Selective Undo

Can’t undo just one operation in middle of history:

1
2
3
4
Workaround:
1. Undo back to that operation
2. Skip it manually
3. Redo the rest

Or just live with linear undo for now.

Combine with Backups

Undo is great, but:

1
2
3
1. Keep notes in version control (git)
2. Use undo for immediate mistakes
3. Use git for long-term recovery

Technical Details

What’s Stored

For each operation:

1
2
3
4
5
6
7
8
9
{
  type: 'delete' | 'rename' | 'move' | 'archive' | 'bulk-delete' | ...,
  timestamp: Date,
  files: [{
    path: string,
    content: string,
    metadata: {...}
  }]
}

Storage Location

Undo history is stored:

  • In VS Code workspace state
  • Survives restarts
  • Workspace-specific

Memory Considerations

Large undo histories can use memory:

  • Each file’s content is stored
  • Large files = more memory
  • Many operations = more memory

If memory is a concern:

  • Clear history periodically
  • Don’t rely on very old undo operations

Limitations

What CAN’T Be Undone

  • Content edits (use VS Code’s editor undo)
  • External file system changes
  • Operations from outside Noted extension
  • Manual file deletions in file explorer

Order Matters

Undo is linear:

  • Can’t undo operation #3 without undoing #1 and #2 first
  • Can’t cherry-pick operations to undo

Conflicts

Undo might fail if:

  • File already exists at restore location
  • Folder structure has changed
  • File system permissions deny operation

In these cases, undo shows error and skips that operation.

Troubleshooting

Undo Not Available

Check:

  • Undo history has operations (run “Show Undo History”)
  • Operation is supported (see Supported Operations)
  • Operation was completed (not canceled)

Redo Not Available

Verify:

  • You’ve undone at least one operation
  • Haven’t performed new operations since undo
  • Redo stack wasn’t cleared

Undo Failed

Possible reasons:

  • File already exists at restore path
  • Permissions issue
  • Folder was deleted
  • External file system change

Solution:

  • Check error message
  • Manually resolve conflict
  • Try undo again

History Too Large

If undo history uses too much memory:

1
Command: Noted: Clear Undo History

Start fresh with smaller history.


Work confidently knowing you can undo mistakes! ↩️

This post is licensed under CC BY 4.0 by the author.