Undo/Redo Edit Stack
Full undo/redo history for all edits
What Is an Undo/Redo Edit Stack?
An undo/redo edit stack is a data structure that records a sequence of operations applied to a dataset and lets you step backward (undo) or forward (redo) through that history. In GIS editing, where a single workflow can involve dozens of vertex moves, attribute edits, cuts, merges, and deletes, a reliable undo/redo system is the difference between a stress-free editing session and a panicked "I've ruined the file" moment. The Undo/Redo Edit Stack tool on gis.tools captures every atomic operation you perform across the editing tools and lets you replay the history or roll back to any earlier state.
The pattern is familiar from text editors, image editors, and any desktop GIS: Ctrl+Z reverses the last operation, Ctrl+Shift+Z (or Ctrl+Y) re-applies a reversed operation. What's less familiar is how the stack is implemented under the hood. Each operation is stored as a delta β the minimum information needed to reverse or replay it β rather than as a full snapshot of the dataset. This keeps memory usage low even for long editing sessions.
Our undo/redo stack spans all the editing tools β Feature Editor, Draw Points/Lines/Polygons, Cut Polygon by Line, Merge Features, Split Multipart Features, Topology Helpers, Geometry Repair β so you can reach into any part of an editing session and reverse a mistake. The stack lives in your browser memory, so it's private, fast, and gone when you close the tab.
How the Undo/Redo Stack Works
Command Pattern
Each user action is encapsulated as a Command object with do() and undo() methods. When you perform an action, the command is executed and pushed onto the stack. When you press undo, the command's undo() method is called and the command moves to a "redo" stack. Pressing redo pops from the redo stack and re-executes.
Delta vs Snapshot
The stack stores deltas β small records of what changed β rather than full snapshots of the dataset. For a vertex move, the delta is the old and new coordinates. For a cut, the delta is the cut line and the resulting pieces. Deltas are typically a few dozen bytes, so thousands of operations consume only a few megabytes.
Branching
Traditional undo/redo is linear: if you undo and then perform a new action, the "future" redo history is discarded. The stack supports this linear model by default; an optional branching mode keeps multiple histories for experimental editing.
Cross-Tool Integration
Because all editing tools use the same stack, undo works across tool switches. You can cut a polygon, switch to the Feature Editor, move a vertex, switch back to the cut tool, and undo all of it in order.
Key Parameters and Options
Stack Depth
Maximum number of operations to keep in history. Default is unlimited (memory permitting).
Autosave Snapshots
Periodically save a full snapshot to browser storage so a browser crash doesn't lose your work.
Operation Grouping
Group multiple small operations (such as individual vertex drags during a single mouse drag) into one undo step.
Keyboard Shortcuts
Ctrl+Z / Cmd+Z for undo, Ctrl+Shift+Z / Cmd+Shift+Z or Ctrl+Y for redo.
Practical Applications
Recovering From Accidents
The most common use: you mis-click and delete a feature, or you drag a vertex to the wrong spot. One undo and the mistake is gone.
Experimental Editing
Try an edit, see if it looks right, undo if not, try again. The stack lets you iterate confidently.
Audit Trail
The list of operations in the stack serves as an informal audit log β what edits were made, in what order.
Teaching
Students can experiment with GIS editing knowing that any mistake is one keystroke away from being fixed. This dramatically lowers the barrier to learning.
Long Editing Sessions
Multi-hour digitizing sessions accumulate many operations. A reliable stack means you don't have to commit every change at once.
Collaborative Review
When reviewing someone else's edits, you can step through the stack to see exactly what they did.
Scripted Playback
Some advanced users export the stack as a script and replay it on a different dataset for reproducibility.
Step-by-Step Workflow in gis.tools
- Any editing tool automatically pushes operations onto the shared undo stack.
- Press Ctrl+Z (or click the Undo button) to reverse the most recent operation.
- Press Ctrl+Shift+Z (or Ctrl+Y) to redo.
- The Undo/Redo panel shows a list of recent operations with short descriptions.
- Click any operation in the list to jump directly to that point in history.
- Enable Autosave if your session will be long.
- Export your edited layer when done β the stack is per-session and does not persist to the exported file.
Worked Example
A GIS analyst is editing a parcel layer in the Feature Editor. She moves 12 parcel corners, cuts one polygon in two, merges two others, and edits several attributes. Halfway through she realizes the cut was in the wrong place. Instead of redoing all subsequent operations, she opens the Undo panel, finds the "Cut Polygon (Polygon 42)" entry, and clicks it. The stack rewinds four operations, undoing them in reverse order. She re-does the cut correctly, and then uses redo to re-apply the subsequent operations that are still valid. Total recovery time: under a minute. Without the stack, this would have been 20 minutes of manual re-editing.
Common Pitfalls and Gotchas
- Stack lost on tab close: The stack lives in browser memory only. Export before closing.
- Redo lost after new action: Performing a new action after undo clears the redo stack.
- Operation grouping surprises: Small operations are sometimes grouped; your undo may reverse more than you expected.
- Memory limits: Very long sessions (tens of thousands of operations) can approach browser memory limits.
- Cross-tool coherence: Some operations span multiple tools and rewind unexpectedly.
- Complex multi-feature edits: An edit that affected many features undoes them all at once, which might not be what you want.
- Attribute history vs geometry history: The stack tracks both; sometimes you want to undo geometry but keep attribute changes.
- Non-undoable operations: Some operations (like format conversion on export) are not recorded because they don't modify the working layer.
Tips for Best Results
- Save early and often. The stack is not a replacement for export.
- Use the Undo panel's jump-to feature for long rewinds.
- Enable autosave for sessions longer than 30 minutes.
- Group related operations with a single multi-select before editing to reduce stack length.
- Don't rely on the stack across tab refreshes β it's in-memory only.
- For multi-session editing, export and reload at the end of each session.
- When in doubt, undo conservatively β one step at a time.
Comparison with Other GIS Approaches
QGIS has an undo panel with full operation history. ArcGIS Pro has undo integrated into its editor. Web editors like iD, Mapbox GL Draw, and TerraDraw provide partial undo. Our browser stack is on par with QGIS for atomic operations and integrates across all editing tools seamlessly.
Performance Considerations
Each stack entry is small (delta-based). Thousands of operations fit in a few megabytes. Undo/redo is O(1) per operation. The limit is browser memory and the number of DOM events fired per undo.
Data Privacy and Browser-Based Processing
The stack is entirely in-browser memory and is not shared with any server. Close the tab and everything is gone.
Related GIS Concepts
- Command pattern: the software design pattern that enables undo/redo.
- Journaling: the database concept of recording changes for rollback.
- Edit session: the period between starting and committing a set of edits.
- Delta: a minimal record of what changed.
- Snapshot: a full copy of state at a point in time.
Frequently Asked Questions
How far back can I undo?
As far as your browser memory allows. Thousands of operations are typical.
Can I save the stack to a file?
Not directly β the stack is in-memory. Export the edited layer to preserve the final state.
Does undo work across tools?
Yes β all editing tools share the same stack.
What if I accidentally hit redo?
Undo again to go back to where you were.
Is there a keyboard shortcut?
Ctrl+Z / Cmd+Z for undo; Ctrl+Shift+Z / Cmd+Shift+Z or Ctrl+Y for redo.
Related Tools on gis.tools
Related Tools
View All ToolsCut Polygon by Line
Split a polygon using a cutting line
Vector EditingFeature Editor
Move, rotate, and reshape features in the browser
Vector EditingSplit Multipart Features
Split MultiPolygon/MultiLineString into single parts
Vector EditingSimplify Preserving Topology
Reduce vertices while maintaining shared boundaries
Vector EditingGeometry Repair
Fix self-intersections and other geometry errors
Vector EditingVertex Density Visualizer
Identify geometries with excessive vertex counts
Vector Editing100% client-side processing - your data stays private and never leaves your device