File tree Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Expand file tree Collapse file tree 1 file changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -260,10 +260,28 @@ def set(self, value: dict) -> None:
260260 cell_id = new_cell .get ("id" )
261261 if cell_id and (old_ycell := old_ycells_by_id .get (cell_id )):
262262 old_cell = self ._cell_to_py (old_ycell )
263- if old_cell == new_cell :
264- new_cell_list .append (old_cell )
265- retained_cells .add (cell_id )
266- continue
263+ if old_cell != new_cell :
264+ # update cell granularly
265+ old_keys = set (old_cell .keys ())
266+ new_keys = set (new_cell .keys ())
267+
268+ shared_keys = old_keys & new_keys
269+ removed_keys = old_keys - new_keys
270+ added_keys = new_keys - old_keys
271+
272+ for key in shared_keys :
273+ if old_cell [key ] != new_cell [key ]:
274+ old_ycell [key ] = new_cell [key ]
275+
276+ for key in removed_keys :
277+ del old_ycell [key ]
278+
279+ for key in added_keys :
280+ old_ycell [key ] = new_cell [key ]
281+
282+ new_cell_list .append (old_cell )
283+ retained_cells .add (cell_id )
284+ continue
267285 # New or changed cell
268286 new_cell_list .append (new_cell )
269287
You can’t perform that action at this time.
0 commit comments