Add better undo support when inserting formatted text

Thanks! Here’s what I noticed don’t handle undo now:

From the composer buttons:

  • Blockquote
  • Bulleted list
  • Numbered list

Other operations (no surprises here):

  • Uploading images via paste
  • @user, #category/tag, :emoji:

Everything else I tried was able to be undone, including basic operations like bold, pasting formatted text, and pasting links on top of text to linkify them.

That said, I did notice some issues when you combine operations that can be undone with those that can’t be.


Bug 1:

  • Open the editor (starting fresh is important)
  • Type hello
  • Delete all text in the editor
  • Hit the Blockquote button (not undoable)
    • Editor now shows > Blockquote
  • Hit Ctrl+Z
    • Editor now shows > Blockquotehello

Bug 2:

  • Open the editor (starting fresh is important)
  • Type hello
  • Hit the Blockquote button (not undoable)
    • Editor now shows hello (newlines) > Blockquote
  • Hit Ctrl+Z five times (notice the cursor move on the fifth time)
  • Hit Ctrl+Y
    Editor now shows hello (newlines) > Blockquotehhello
  • Keep hitting Ctrl+Y
    • Editor now shows hello (newlines) > Blockquotehellohello

The number of times you have to hit undo before this activates depends on how many letters you typed originally (hello in my example).

Note that this can also happen for things like mentions instead of hitting the blockquote button, but it’s even weirder since you have to type to get suggestions for mentions. So when you “redo”, that text partially appears. For example:

  • Type “hello @dav” and select your username from the suggestion list (not undoable)
  • Hit Ctrl+Z until the cursor moves to the beginning of the editor like in the previous example
  • Hit Ctrl+Y
    • Editor now shows hello @david hhello @dav
  • Keep hitting Ctrl+Y
    • Editor now shows hello @david hello @davhello @dav
1 Like