App Crash during undo from new empty line in code block

Testing version:
Version 2.0 (10936)

What were you doing:
Trying to undo text inside of a code block

What feature did you use:
Code block

What happened:
The app crashed.

What did you expect to happen:
I expected the app to undo changes in the note.

Ideas as to why this seems to happen:

  • The app seems to not like when undo is invoked and the last thing that happened is an empty line with a non empty line above inside of a code block.
  • Undo is invoked when the last two actions from newest to oldest are: [new line (line 2 of a code block), changes to text (line 1 of a code block)]

Steps to reproduce:

  1. Create a code block
  2. On the first line of the code block, add some text
  3. Create a new empty line as line 2 in the code block (return key)
  4. Undo via menu or cmd + z
  5. After you reopen the app, remove some characters from line 1 of the code block
  6. Repeat step 3 (you don’t need to remove the previous new line either)
  7. Repeat step 4

Here’s a video demonstrating the crash.


Once this gets fixed, I’d be curious as to what exactly was causing this.

3 Likes

Hello!

Thank you for reporting it, we’ve just fixed in our internal version :slight_smile:

As for what was causing it, it’s… complex:

  1. there is some code that’s fixing a rendering bug inside the code block when a newline is inserted
  2. that code was incorrectly running during an undo operation
  3. so instead of having the correct string/attributes after the undo we had a string without attributes
  4. the markdown hider depends on those attributes
  5. boom
1 Like

Ahhh interesting. I was curious what the fix was cause I knew it had to be something tricky going on under the hood.

Thanks for the follow up, @matteo!