microsoft/vscode

Create an undo stop when alternating between constructive edits, destructive edits, and cursor navigation

axefrog opened this issue ยท 2 comments

  • VSCode Version: 1.13.0
  • OS Version: Windows 10

VSCode's undo behaviour seems unusually coarse and not in line with how other editing experiences work. Often I accidentally hit the wrong key while something is selected and accidentally overwrite what I'd written. Then when I hit undo, it undoes not only what I just did, but a whole lot of what I'd done previously. Undo is supposed to save the user from these sorts of problems.

Steps to Reproduce:

  1. Type some words
  2. Delete the last word
  3. Type some more words
  4. Decide you don't like your change and hit undo

The entire sentence vanishes.

Undo stops should occur (roughly) in the following scenarios:

  • When starting a new destructive operation (backspace, delete, cut, etc.) after a constructive operation (typing, pasting, other insertion scenarios).
  • The inverse of the above; starting a new constructive operation after a destructive operation.
  • Between different classes of destructive or constructive edit - for example if I backspace a few times, removing characters left of the cursor, and then use the delete key, removing characters to the right of the cursor, I'd expect an undo stop to occur when the delete key is first pressed.
  • Starting to navigate and/or select text with the cursor after any kind of edit, or starting an edit operation after navigating with the cursor.

Currently, undo stops are inserted at any cursor movement operation, and any editing operation (such as typing or deleting) does not insert undo stops, so I think your last bullet point is already covered.

๐Ÿ‘ I like the other 3 bullet points

Wow, looks like this is fixed, then? Great work! :-)