Skip to content

Fix #781: click highlights member references, Ctrl+Click navigates - #3923

Merged
siegfriedpammer merged 1 commit into
masterfrom
feature-781-member-highlight
Jul 28, 2026
Merged

Fix #781: click highlights member references, Ctrl+Click navigates#3923
siegfriedpammer merged 1 commit into
masterfrom
feature-781-member-highlight

Conversation

@siegfriedpammer

Copy link
Copy Markdown
Member

Fixes #781.

Clicking a local variable highlights its occurrences, but clicking a member or type always navigated away, so there was no way to see all uses of a member within the current view.

Behavior (per the implementation suggestions in the issue):

  • New display setting, off by default: "Single-click highlights member references (Ctrl+Click navigates)".
  • With the setting enabled, a single click on a member or type reference paints every occurrence in the view using the local-reference highlight infrastructure; Ctrl+Click performs the navigation. Opcode references in the IL view keep navigating on plain click.
  • The hand cursor is shown only when a click would actually navigate: cursor queries factor in the setting and the Ctrl state, and pressing/releasing Ctrl while hovering a reference repaints the cursor immediately (top-level key handlers, since keyboard focus is usually elsewhere while hovering).
  • With the setting disabled, behavior is unchanged — pinned by tests.

Matching: occurrences are compared by definition token and module rather than Equals, because a use site carries a specialized member instance (List<int>.Add) while the declaration carries the definition — the same mismatch class as #2078. This also fixes the analyzer-driven highlight for specialized members. Unresolved entity references from the IL/metadata views are compared structurally (module + handle) to avoid building a type system per click.

Tests: MemberReferenceHighlightTests (8, red-first): default-off pin, highlight-all, specialized-member matching, type parameterization matching, Ctrl navigation, clear behavior, an end-to-end pointer test with real RawInputModifiers.Control mouse events, and a cursor test asserting hand-only-when-navigating. Full ILSpy.Tests: 1077 passed / 3 skipped.

🤖 This PR was prepared by an AI agent (Claude Code) operated by @siegfriedpammer.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an optional (default-off) interaction mode in the decompiler text view where a plain click highlights all occurrences of member/type references in the current document, while Ctrl+Click performs navigation; also updates cursor affordances and adds regression tests.

Changes:

  • Introduces DisplaySettings.HighlightMemberReferences and surfaces it in the Display options UI (default: off).
  • Extends reference-click handling to highlight member/type references on plain click when enabled, with Ctrl+Click preserving navigation.
  • Adds cursor-query plumbing (key-modifier aware) plus a new headless UI test suite covering highlighting, navigation, and cursor behavior.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
ILSpy/TextView/VisualLineReferenceText.cs Delegates cursor selection to the host when available (modifier/settings-aware).
ILSpy/TextView/ReferenceElementGenerator.cs Adds QueryCursor hook so the view can decide cursor behavior for references.
ILSpy/TextView/DecompilerTextView.axaml.cs Implements highlight-vs-navigate toggle, Ctrl-modified navigation, and cursor update logic.
ILSpy/Properties/Resources.resx Adds localized string for the new display setting label.
ILSpy/Properties/Resources.Designer.cs Adds strongly-typed accessor for the new resource string.
ILSpy/Options/DisplaySettingsPanel.axaml Adds checkbox to toggle member-reference click highlighting.
ILSpy/Options/DisplaySettings.cs Adds persisted setting HighlightMemberReferences (default-off).
ILSpy/Options/DisplaySettingReactions.cs Marks the new setting as EditorLive (no redecompile needed).
ILSpy.Tests/Editor/MemberReferenceHighlightTests.cs Adds headless tests covering default-off behavior, highlight matching, Ctrl navigation, pointer events, and cursor affordance.
Files not reviewed (1)
  • ILSpy/Properties/Resources.Designer.cs: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ILSpy/TextView/DecompilerTextView.axaml.cs Outdated
Comment thread ILSpy/TextView/DecompilerTextView.axaml.cs
Clicking a local variable highlights its occurrences, but clicking a
member or type always navigated away, so there was no way to see all
uses of a member within the current view. With the new display setting
enabled (off by default, as discussed in the issue), a single click on
a member or type reference paints every occurrence in the view using
the local-reference highlight infrastructure, and Ctrl+Click performs
the navigation. Opcode references keep navigating on plain click.

Matching occurrences are compared by definition token and module
rather than by Equals, because a use site carries a specialized member
instance while the declaration carries the definition; this also fixes
the analyzer-driven highlight for specialized members. Unresolved
entity references from the IL and metadata views are compared
structurally to avoid building a type system per click.

The hand cursor promises navigation, so it is shown only when a click
would actually navigate: cursor queries factor in the setting and the
Ctrl state, and Ctrl presses/releases while hovering a reference
repaint the cursor via top-level key handlers, since keyboard focus is
usually elsewhere while hovering.

Assisted-by: Claude:claude-fable-5:Claude Code
@siegfriedpammer
siegfriedpammer force-pushed the feature-781-member-highlight branch from 0858774 to 2032766 Compare July 28, 2026 12:31
@siegfriedpammer
siegfriedpammer merged commit 48fb859 into master Jul 28, 2026
13 checks passed
@siegfriedpammer
siegfriedpammer deleted the feature-781-member-highlight branch July 28, 2026 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text Highlight

2 participants