diff --git a/lib/livebook/session/data.ex b/lib/livebook/session/data.ex index cb63be8bc..8e938c8a1 100644 --- a/lib/livebook/session/data.ex +++ b/lib/livebook/session/data.ex @@ -1109,7 +1109,7 @@ defmodule Livebook.Session.Data do notebook: Notebook.delete_cell(data.notebook, cell.id), bin_entries: [ %{ - cell: cell, + cell: Map.replace(cell, :outputs, []), section_id: section.id, section_name: section.name, index: Enum.find_index(section.cells, &(&1 == cell)), diff --git a/test/livebook/session/data_test.exs b/test/livebook/session/data_test.exs index 93abbb899..f443967aa 100644 --- a/test/livebook/session/data_test.exs +++ b/test/livebook/session/data_test.exs @@ -780,6 +780,21 @@ defmodule Livebook.Session.DataTest do refute Map.has_key?(cell_infos, "c1") end + test "does not include cell outputs in deleted cells" do + data = + data_after_operations!([ + {:insert_section, @cid, 0, "s1"}, + {:insert_cell, @cid, "s1", 0, :code, "c1", %{}}, + {:set_runtime, @cid, connected_noop_runtime()}, + evaluate_cells_operations(["setup", "c1"]) + ]) + + operation = {:delete_cell, @cid, "c1"} + + assert {:ok, %{bin_entries: [%{cell: %{id: "c1", outputs: []}}]}, _actions} = + Data.apply_operation(data, operation) + end + test "unqueues the cell if it's queued for evaluation" do data = data_after_operations!([