mirror of
https://github.com/livebook-dev/livebook.git
synced 2024-12-27 09:53:08 +08:00
Handle output even after cell finishes evaluation (#272)
This commit is contained in:
parent
937597d6c0
commit
61a841a6d2
2 changed files with 24 additions and 2 deletions
|
@ -266,8 +266,7 @@ defmodule Livebook.Session.Data do
|
|||
end
|
||||
|
||||
def apply_operation(data, {:add_cell_evaluation_stdout, _client_pid, id, string}) do
|
||||
with {:ok, cell, _} <- Notebook.fetch_cell_and_section(data.notebook, id),
|
||||
:evaluating <- data.cell_infos[cell.id].evaluation_status do
|
||||
with {:ok, cell, _} <- Notebook.fetch_cell_and_section(data.notebook, id) do
|
||||
data
|
||||
|> with_actions()
|
||||
|> add_cell_evaluation_stdout(cell, string)
|
||||
|
|
|
@ -856,6 +856,29 @@ defmodule Livebook.Session.DataTest do
|
|||
}
|
||||
}, []} = Data.apply_operation(data, operation)
|
||||
end
|
||||
|
||||
test "adds output even after the cell finished evaluation" do
|
||||
data =
|
||||
data_after_operations!([
|
||||
{:insert_section, self(), 0, "s1"},
|
||||
{:insert_cell, self(), "s1", 0, :elixir, "c1"},
|
||||
{:queue_cell_evaluation, self(), "c1"},
|
||||
{:add_cell_evaluation_response, self(), "c1", {:ok, [1, 2, 3]}}
|
||||
])
|
||||
|
||||
operation = {:add_cell_evaluation_stdout, self(), "c1", "Hello!"}
|
||||
|
||||
assert {:ok,
|
||||
%{
|
||||
notebook: %{
|
||||
sections: [
|
||||
%{
|
||||
cells: [%{outputs: ["Hello!", _result]}]
|
||||
}
|
||||
]
|
||||
}
|
||||
}, []} = Data.apply_operation(data, operation)
|
||||
end
|
||||
end
|
||||
|
||||
describe "apply_operation/2 given :add_cell_evaluation_response" do
|
||||
|
|
Loading…
Reference in a new issue