Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions dev/live_views/main.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ defmodule LiveDebuggerDev.LiveViews.Main do
|> assign(func: fn a -> {:ok, a} end)
|> assign(single_element_list: [%Phoenix.LiveComponent.CID{cid: 1}])
|> assign(list: [%Phoenix.LiveComponent.CID{cid: 1}, %Phoenix.LiveComponent.CID{cid: 2}])
|> assign(
cid_map: %{
%Phoenix.LiveComponent.CID{cid: 1} => "1",
%Phoenix.LiveComponent.CID{cid: 2} => DateTime.utc_now(),
DateTime.utc_now() => "DateTime"
}
)
|> assign(
long_assign:
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
Expand Down
3 changes: 3 additions & 0 deletions lib/live_debugger/utils/term_parser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ defmodule LiveDebugger.Utils.TermParser do

%{content: [span]} ->
{%{span | text: inspect(key, width: :infinity)}, black(" => ")}

%{content: _content} ->
{%{text: inspect(key, width: :infinity), color: "text-code-1"}, black(" => ")}
end

case to_node(value, suffix) do
Expand Down
41 changes: 41 additions & 0 deletions test/utils/term_parser_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,47 @@ defmodule LiveDebugger.Utils.TermParserTest do

assert TermParser.term_to_display_tree(term) == expected
end

test "parses map with struct keys correctly" do
term = %{
%Phoenix.LiveComponent.CID{cid: 1} => "CID",
Date.new(2025, 7, 8) => "Date"
}

expected = %{
kind: "map",
children: [
%{
kind: "binary",
children: nil,
content: [
%{text: "{:ok, ~D[2025-07-08]}", color: "text-code-2"},
%{text: " => ", color: "text-code-2"},
%{text: "\"Date\"", color: "text-code-4"},
%{text: ",", color: "text-code-2"}
],
expanded_before: nil,
expanded_after: nil
},
%{
kind: "binary",
children: nil,
content: [
%{text: "%Phoenix.LiveComponent.CID{cid: 1}", color: "text-code-1"},
%{text: " => ", color: "text-code-2"},
%{text: "\"CID\"", color: "text-code-4"}
],
expanded_before: nil,
expanded_after: nil
}
],
content: [%{text: "%{...}", color: "text-code-2"}],
expanded_before: [%{text: "%{", color: "text-code-2"}],
expanded_after: [%{text: "}", color: "text-code-2"}]
}

assert TermParser.term_to_display_tree(term) == expected
end
end

describe "term_to_copy_string/1" do
Expand Down