Clear cell outputs when moving to bin (#2312)

This commit is contained in:
Jonatan Kłosko 2023-10-27 21:35:41 +02:00 committed by GitHub
parent c0e75f64ad
commit a0cc26fd47
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View file

@ -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)),

View file

@ -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!([