-
Notifications
You must be signed in to change notification settings - Fork 745
Fix unhandled exception when double-clicking in scroll bar area with no selected nodes #2254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
… related methods Co-authored-by: brianrob <6210322+brianrob@users.noreply.github.com>
The current implementation is functionally correct, but has regressed performance when scrolling in the stack viewer. Scrolling without the change is very smooth, but is super-choppy with the change. I captured before and after traces, and found that there are a couple of differences worth calling out:
Regressed:
Baseline:
@copilot, please investigate further and see if you can make a fix that addresses the functional issue without regressing performance. |
…mouse double-click handling Co-authored-by: brianrob <6210322+brianrob@users.noreply.github.com>
Fixed the performance regression in commit b7b0395. The issue was that my original fix added GetSelectedNodes() calls to all Do* methods, creating unnecessary object allocations during normal command execution. The WPF command system already handles CanExecute validation with SingleNodeIsSelected, so those defensive checks were redundant. I reverted those changes and instead added a targeted check only in ByName_MouseDoubleClick before calling DoViewInCallers. This approach:
|
Problem
Double-clicking in the right scroll bar area of the StackWindow causes an unhandled exception crash with the error "Sequence contains no elements". This occurs when clicking rapidly on scroll arrows to navigate upwards and reaching the end, or when double-clicking on the scroll bar when no nodes are selected.
The issue stems from the
ByName_MouseDoubleClick
event handler directly callingDoViewInCallers
, which then callsGetSelectedNodes().Single()
without checking if any nodes are actually selected.Root Cause
The stack trace shows:
When a user double-clicks on the scroll bar area, the mouse event bypasses the command system's
CanExecute
checks that would normally prevent execution when no nodes are selected. TheByName_MouseDoubleClick
method directly callsDoViewInCallers(sender, null)
, which then attempts to call.Single()
on an empty collection returned byGetSelectedNodes()
.Solution
Added defensive checks in all methods that call
GetSelectedNodes().Single()
to handle empty selections gracefully:DoViewInCallers
- Primary method from stack traceDoViewInCallees
- Same pattern, same riskDoViewInCallerCallee
- Same pattern, same riskDoFindInByName
- Same pattern, same riskDoFindInCallTreeName
- Same pattern, same riskDoGotoSource
- Same pattern, same riskEach method now checks
if (selectedNodes.Count == 0)
and returns early if no nodes are selected, preventing the crash while maintaining all existing functionality.Testing
GetSelectedNodes()
in the codebase are already safeCode Quality
Fixes #2253.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.