Skip to content

Commit e59b4e6

Browse files
committed
Add type guard, fix text removal
1 parent 675da6f commit e59b4e6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

jupyter_ydoc/ynotebook.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,12 @@ def _update_cell(self, old_cell: dict, new_cell: dict, old_ycell: Map) -> bool:
352352

353353
if key in _CELL_KEY_TYPE_MAP:
354354
kind = _CELL_KEY_TYPE_MAP[key]
355-
if kind == Text and value:
355+
356+
if not isinstance(old_ycell[key], kind):
357+
# if our assumptions about types do not, fall back to hard update
358+
return False
359+
360+
if kind == Text:
356361
old: Text = old_ycell[key]
357362
old.clear()
358363
old.insert(0, value)

0 commit comments

Comments
 (0)