marimo-team / marimo

A reactive notebook for Python — run reproducible experiments, execute as a script, deploy as an app, and version with git.
https://marimo.io
Apache License 2.0
6.63k stars 228 forks source link

Cell undo does not preserve cell language #2509

Open akshayka opened 2 hours ago

akshayka commented 2 hours ago

Describe the bug

We have a bug in which the undo delete cell operation brings doesn't preserve the cell language.

  1. Create a "markdown" cell
  2. Delete the markdown cell
  3. Undo the deletion

Today, after 3., the cell is incorrectly brought back as a Python cell, but it should be a markdown cell. Here is an example of an incorrect cell being brought back after undo:

image

SQL cells have the same problem.

Possible fixes:

  1. Preserve the cell language in the undo/redo stack.
  2. Only keep track of the underlying Python code in the undo/redo stack (in which case it would be okay to bring any cell back as a Python cell).

Environment

HEAD

Code to reproduce

No response

mscolnick commented 2 hours ago

We should do number #2. It should be a one line change, with probably a 20 line unit test.