Repository navigation
Conversation
…tepping The Variables view saves and restores the expanded nodes and the selection per stack frame, keyed by XStackFrame.getEqualityObject(), only when that object is non-null. DAPStackFrame didn't override it, so every rebuild of the view (after "Set Value...", after each step) started collapsed. Use the function name and the source of the DAP frame. The frame id changes on each stop and the line on each step, so neither is part of it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1937 +/- ##
==========================================
+ Coverage 48.17% 48.24% +0.06%
==========================================
Files 809 809
Lines 32435 32445 +10
Branches 6600 4998 -1602
==========================================
+ Hits 15626 15652 +26
+ Misses 14314 14306 -8
+ Partials 2495 2487 -8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
In a DAP debug session, the Variables view collapses each time it is rebuilt:
itemand every other expanded entry are collapsed again, and have to be expanded by hand to see the new value;The Java debugger keeps the expanded entries in both cases.
Cause
Claude Code traced it in the IntelliJ Platform sources:
setVariable,DAPValueModifiercallscallback.valueModified(). The platform's callback (DebuggerUIUtil, around line 648 inintellij-community) then callsrebuildAllSessionsViews(project), which rebuilds the Variables view from the current stack frame.XVariablesViewBase(buildTreeAndRestoreState,saveCurrentTreeState) saves and restores the expanded nodes and the selection per stack frame, keyed byXStackFrame.getEqualityObject(). It only does this when that object is non-null.XStackFrame.getEqualityObject()returnsnullby default, andDAPStackFramedoesn't override it. So the platform never saves or restores the tree state for a DAP frame, and every rebuild starts collapsed.The JavaDoc of
getEqualityObject()says the same for stepping: "If the stack frame is not changed after stepping in the debugger, the expanded nodes and the selection will be restored". So the same cause also collapses the tree after every step in a DAP session, not only after "Set Value…".Reloading the values isn't the problem:
variablesReferencevalues change on each fetch anyway (the trace showsitemas 7, 83, 159, 235, …). The platform restores the tree by node names (scope groups such asLocals, then variable names), so it can restore the state although the references change.Change
DAPStackFrame(src/main/java/com/redhat/devtools/lsp4ij/dap/client/DAPStackFrame.java) overridesgetEqualityObject()with a value that stays the same while the user is "in the same function", but changes for a different one: the frame's name and its source (the path, elseref:<sourceReference>for asourceReference > 0, else the source name).Not in the key:
StackFrame.id: it changes with every stop, so the state would never be restored.Other debuggers in the IntelliJ Platform do the same or less:
JavaStackFrame) keys on the declaring type and the method signature (NodeManagerImpl.getContextKeyForFrame), without the line or the depth.PyStackFrame) uses one constant object for every frame.So a recursive call of the same function at another depth shares the state, as in the Java debugger. That only decides which nodes are open; the values are always fetched again.
Requests: LSP4IJ already sends
variablesfor every scope of the frame on each stop,expensiveones included (DAPStackFrame.computeChildren). This change doesn't touch that. What it adds is onevariablesrequest for each entry the user had expanded, hereitem, which the user would otherwise send by expanding it by hand.Tests
DAPStackFrameEqualityTest(6 tests, all pass):idandline→ equalsourceReference→ equal; othersourceReference→ differentManual test in IntelliJ IDEA 2026.3 with the JSC debug adapter (
jsc-debug) andswift/Tests/Fixtures/set-variable.js, stopped at line 24 withitemexpanded:Before:
itemis collapsed;Localsshows only its top-level entries, followed by the groupsGlobal (lexical),GlobalandDiagnostics.itemhas to be expanded again by hand.Before, "Set Value…" (
count→42):dap-variables-tree-before-set-value.mp4
Before, Step Over (line 24 → 25):
dap-variables-tree-before-step-over.mp4
After: the view shows "Collecting data…" for a moment, then
itemis expanded again, withcount = 42.After, "Set Value…":
dap-variables-tree-after-set-value.mp4
After, Step Over:
dap-variables-tree-after-step-over.mp4
🤖 Generated with Claude Code