Fix MapSet assign summary updates#988
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a bug where collapsed display of a struct (e.g., MapSet) was not refreshed after a diff update, so users saw the original inspect output even after the value changed. The fix carries the full updated/old struct in the :struct diff and uses it to regenerate the struct's collapsed content while preserving children diffs and expansion state.
Changes:
TermDiffer.diff/2for structs now populates:ins/:delwith the new and old struct under theprimitive_key.TermParser.update_by_diff!/3for:structnow refreshes the node's content/kind/key/expanded markers from the new struct via a newrefresh_struct_content/3helper, before applying child diffs.- Adds tests covering the new diff shape and the collapsed-content refresh (including a
MapSetregression case).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| lib/live_debugger/app/utils/term_differ.ex | Includes full old/new struct in :struct diff via ins/del. |
| lib/live_debugger/app/utils/term_parser.ex | Regenerates struct display content from updated struct while preserving children/state. |
| test/app/utils/term_differ_test.exs | Updates struct diff expectation to include ins/del. |
| test/app/utils/term_parser_test.exs | Adds regression test for MapSet collapsed content update. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- TermDiffer.diff/2 for structs no longer carries `del` — the struct refresh in TermParser only reads `ins`, so retaining the old struct was dead weight and extra memory (per @GuzekAlan). - TermParser uses a `@primitive_key` module attribute instead of calling TermDiffer.primitive_key/0 per invocation (per @GuzekAlan). - Update term_differ_test struct-diff expectation to match.
|
Thanks for the review @GuzekAlan — both points addressed in 4ca82c9:
Compiles clean with |
…summary_node to avoid unnecessary children recalc
|
Addressed the latest review comments:
Ready for re-review / merge. This keeps the child diff/expansion state intact while fixing the collapsed summary for changing |
Co-authored-by: Alan Guzek <alanguzek@gmail.com>
* fix MapSet assign summary updates * Update lib/live_debugger/app/utils/term_parser.ex --------- Co-authored-by: Alan Guzek <alanguzek@gmail.com>
* fix MapSet assign summary updates * Update lib/live_debugger/app/utils/term_parser.ex --------- Co-authored-by: Alan Guzek <alanguzek@gmail.com>
Summary
MapSetassign whose collapsed summary changes after a diff update.Fixes #986
Validation
mix format --check-formatted lib/live_debugger/app/utils/term_differ.ex lib/live_debugger/app/utils/term_parser.ex test/app/utils/term_differ_test.exs test/app/utils/term_parser_test.exsmix test test/app/utils/term_differ_test.exs test/app/utils/term_parser_test.exs test/app/debugger/node_state/queries_test.exs test/app/debugger/node_state/web/components_test.exsmix test