Repository navigation
fix(dap): bring the debugger to the front when any kind of breakpoint stops the program - #2004
Conversation
… stops the program
A stop which LSP4IJ doesn't match to an IntelliJ breakpoint, such as an
exception, or a function or data breakpoint without hitBreakpointIds, was
reported with positionReached(context), which never attracts the user. Now
a stop whose reason is breakpoint, exception, function breakpoint, data
breakpoint or instruction breakpoint calls
XDebugSessionImpl.positionReached(context, true) by reflection, as
breakpointReached does. Without that method, the session is told with
positionReached(context) and the Debugger tab is selected with
attractBy("breakpoint"). Steps, pauses and stops on entry are unchanged.
Fixes redhat-developer#2003
Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2004 +/- ##
==========================================
- Coverage 49.13% 49.12% -0.01%
==========================================
Files 812 812
Lines 32975 33005 +30
Branches 5101 6747 +1646
==========================================
+ Hits 16201 16213 +12
- Misses 14234 14249 +15
- Partials 2540 2543 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
@coderabbitai review |
Action performed
|
|
@muescha Thanks for the PR, and for laying out the options in #2003. We'd like to take this in 0.31.0 rather than in 0.30.0:
I've set the milestone to 0.31.0. |
Fixes #2003
Summary
When a DAP program stops and LSP4IJ doesn't find an IntelliJ breakpoint for the stop, it reports the stop with
XDebugSession.positionReached(context). That never attracts the user, so the Debug tool window stays on the Console tab. This happens for exceptions, and for function and data breakpoints when the adapter sends nohitBreakpointIds.With this change, a stop whose reason says that a breakpoint of any kind stopped the program brings the debugger to the front, as an IntelliJ breakpoint does. Steps, pauses and stops on entry are unchanged.
Changes
DAPClient.isBreakpointReason(reason)(new):breakpoint,exception,function breakpoint,data breakpointandinstruction breakpointare breakpoint reasons;step,goto,pause,entry, unknown reasons and none are not.DAPClient.positionReached(session, context, reason)(new), used bysuspendwhere it calledpositionReached(context)before:session.positionReached(context), as before.XDebugSessionImpl.positionReached(context, true), called by reflection throughBreakpointInternalSupport. This is whatbreakpointReacheddoes: it brings the Debug tool window to the front (when "Show debug window on breakpoint" is on) and selects the Debugger tab (Variables in the classic UI).XDebugSessionImpl:session.positionReached(context), thensession.getUI().attractBy("breakpoint")on the EDT. This selects the tab but doesn't bring the tool window to the front.breakpointReached, so nothing changes there.BreakpointInternalSupportis now public (@ApiStatus.Internal), sinceDAPClientis in another package, with the new public methodpositionReached(XDebugSession, XSuspendContext, boolean). There is still no compile-time dependency onXDebugSessionImpl. The method exists in 2024.2 (the lowest supported version) and in 2026.3.IntelliJ still selects the tab only at the first breakpoint of a session (
LayoutAttractionPolicy.FocusOnce); later stops make it bounce. This is the same as in the Java debugger, and this PR doesn't change it (variant B in #2003).Open questions
entry(stop on entry) doesn't attract the user. It isn't a breakpoint in DAP, but users ask for it in the launch configuration, much like a breakpoint on the first line. Should it attract too?Tests
DAPClientAttractOnStopTest:nulland an unknown reason).XDebugSessionImplcallspositionReached(context), thenattractBy("breakpoint").positionReached(context).XDebugSessionImpl.positionReached(XSuspendContext, boolean)exists on the platform of the tests.BreakpointInternalSupport.positionReachedleaves a session that is not anXDebugSessionImplto the caller.The call with
attract = trueon a realXDebugSessionImplis not covered by a unit test; it is checked in the IDE below../gradlew test --tests 'com.redhat.devtools.lsp4ij.dap.*': 332 tests, all pass../gradlew buildPlugin: passes.Checked in the IDE
Claude Code ran
runIde(IntelliJ IDEA Community 2024.2 sandbox) and debugged this script with the debugpy bundled in IntelliJ IDEA 2026.3, with the Console tab in front:On
main, the uncaughtValueErrorstops the program (reasonexception), but the Console stays in front:With this PR, the same stop selects the Threads & Variables tab:
A line breakpoint still selects the tab, as before:
After selecting the Console again, a step over leaves it in front:
Not checked:
pause. This sandbox offered no Pause action for the session. The code path is the same as for a step, and the unit test covers it.Relation to #2002
#2002 (for #1999) changes one line of
DAPClient.suspend(the lookup of the breakpoint on the line). This PR changes thepositionReachedcall further down. The change applies cleanly on top of #2002.🤖 Generated with Claude Code