mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-09-05 04:24:21 +08:00
Fix nested frame updates (#1251)
This commit is contained in:
parent
cb0a208274
commit
5c0ad7ba1d
2 changed files with 26 additions and 1 deletions
|
@ -722,7 +722,7 @@ defmodule Livebook.Notebook do
|
|||
end
|
||||
|
||||
defp do_find_frame_outputs({_idx, {:frame, outputs, _info}}, ref) do
|
||||
Enum.flat_map(outputs, &find_frame_outputs(&1, ref))
|
||||
Enum.flat_map(outputs, &do_find_frame_outputs(&1, ref))
|
||||
end
|
||||
|
||||
defp do_find_frame_outputs(_output, _ref) do
|
||||
|
|
|
@ -403,4 +403,29 @@ defmodule Livebook.NotebookTest do
|
|||
)
|
||||
end
|
||||
end
|
||||
|
||||
describe "find_frame_outputs/2" do
|
||||
test "returns frame outputs with matching ref" do
|
||||
frame_output = {0, {:frame, [], %{ref: "1", type: :default}}}
|
||||
|
||||
notebook = %{
|
||||
Notebook.new()
|
||||
| sections: [%{Section.new() | cells: [%{Cell.new(:code) | outputs: [frame_output]}]}]
|
||||
}
|
||||
|
||||
assert [^frame_output] = Notebook.find_frame_outputs(notebook, "1")
|
||||
end
|
||||
|
||||
test "finds a nested frame" do
|
||||
nested_frame_output = {0, {:frame, [], %{ref: "2", type: :default}}}
|
||||
frame_output = {0, {:frame, [nested_frame_output], %{ref: "1", type: :default}}}
|
||||
|
||||
notebook = %{
|
||||
Notebook.new()
|
||||
| sections: [%{Section.new() | cells: [%{Cell.new(:code) | outputs: [frame_output]}]}]
|
||||
}
|
||||
|
||||
assert [^nested_frame_output] = Notebook.find_frame_outputs(notebook, "2")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue