Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Yr Blues

macrumors 68030
Original poster
Jan 14, 2008
2,803
1,082
Sometimes I'm typing a long thing and mess up then hit Undo (command-Z) and it takes me really far back, like several paragraphs. Sometimes it Undos just a few words. What are the parameters that it is making for Undo instances?
 
The undoable text sequence is the longest string of uninterrupted keystrokes that produce text.

An "interruption" in the undoable keystroke sequence is any event that moves the text cursor position to a place other than where the last keystroke was appended, or a cmd-keystroke event that triggers an action, such as ⌘Z.

Examples of keystrokes that will interrupt an undoable keystroke sequence:
- arrow keys followed by any editing (addition or removal of text)
- ⌘Z (Undo) or ⌘V (Paste)
- most menu actions like ⌘S (Save)

Examples of non-keystroke events what WON'T interrupt an undoable keystroke sequence:
- click a menu, then click off it without choosing any menu action.
- cmd-click a window title-bar to drag it without activating it.

The examples are not exhaustive lists. I may be mistaken on some examples, or it may depend on OS version.
 
  • Like
Reactions: Yr Blues
backspace, backspace !
Also, SHIFT+OPTION+left-arrow will select the entire word to the left of the cursor. This can be repeated to select multiple words.Then press BACKSPACE.

And SHIFT+CMD+left-arrow will select the entire previous line.
 
The undoable text sequence is the longest string of uninterrupted keystrokes that produce text.

An "interruption" in the undoable keystroke sequence is any event that moves the text cursor position to a place other than where the last keystroke was appended, or a cmd-keystroke event that triggers an action, such as ⌘Z.

Examples of keystrokes that will interrupt an undoable keystroke sequence:
- arrow keys followed by any editing (addition or removal of text)
- ⌘Z (Undo) or ⌘V (Paste)
- most menu actions like ⌘S (Save)

Examples of non-keystroke events what WON'T interrupt an undoable keystroke sequence:
- click a menu, then click off it without choosing any menu action.
- cmd-click a window title-bar to drag it without activating it.

The examples are not exhaustive lists. I may be mistaken on some examples, or it may depend on OS version.
Where did you this? Great stuff.
 
Where did you this? Great stuff.
I write software. It's pretty much how any Undo logic will work if it coalesces like operations.

For example, if the Undo buffer is empty (nothing to undo) and a keystroke is received, then it goes into the document at the current text-cursor position, and it goes into the Undo buffer (i.e. that keystroke can now be undone). The next keystroke comes in, so it's appended to the document and to the Undo buffer. The Undo manager sees the prior event is a text keystroke, so it coalesces the two events into a single string. Repeat for more keystrokes.

If an event comes in that moves the cursor, then that ends the coalescing of like operations (text keystrokes), and begins a new undoable sequence at the new cursor location.

That's the simplified logic, because reality is always more complicated, but it's the gist of it.
 
  • Like
Reactions: Yr Blues
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.