mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-02-20 21:04:17 +08:00
Respect \r in individual stdout results
This commit is contained in:
parent
4badf40afc
commit
87a17f1fc5
2 changed files with 25 additions and 0 deletions
|
@ -854,6 +854,8 @@ defmodule Livebook.Session.Data do
|
|||
)
|
||||
end
|
||||
|
||||
defp add_output([], output) when is_binary(output), do: [apply_rewind(output)]
|
||||
|
||||
defp add_output([], output), do: [output]
|
||||
|
||||
defp add_output([head | tail], output) when is_binary(head) and is_binary(output) do
|
||||
|
|
|
@ -1814,6 +1814,29 @@ defmodule Livebook.Session.DataTest do
|
|||
}, []} = Data.apply_operation(data, operation)
|
||||
end
|
||||
|
||||
test "normalizes individual stdout results to respect CR" do
|
||||
data =
|
||||
data_after_operations!([
|
||||
{:insert_section, self(), 0, "s1"},
|
||||
{:insert_cell, self(), "s1", 0, :elixir, "c1"},
|
||||
{:set_runtime, self(), NoopRuntime.new()},
|
||||
{:queue_cells_evaluation, self(), ["c1"]}
|
||||
])
|
||||
|
||||
operation = {:add_cell_evaluation_output, self(), "c1", "Hola\rHey"}
|
||||
|
||||
assert {:ok,
|
||||
%{
|
||||
notebook: %{
|
||||
sections: [
|
||||
%{
|
||||
cells: [%{outputs: ["Hey"]}]
|
||||
}
|
||||
]
|
||||
}
|
||||
}, []} = Data.apply_operation(data, operation)
|
||||
end
|
||||
|
||||
test "normalizes consecutive stdout results to respect CR" do
|
||||
data =
|
||||
data_after_operations!([
|
||||
|
|
Loading…
Reference in a new issue