Skip to content

Fix reactive highlighting of property access names#8725

Open
manzt wants to merge 1 commit intomainfrom
push-rqplrprqvouq
Open

Fix reactive highlighting of property access names#8725
manzt wants to merge 1 commit intomainfrom
push-rqplrprqvouq

Conversation

@manzt
Copy link
Collaborator

@manzt manzt commented Mar 17, 2026

Reactive variable highlighting was incorrectly decorating property names when they matched a known variable. For example, given variables mcp and tool, the expression mcp.tool would highlight both mcp and tool, even though tool after the dot is a property access, not a variable reference. This was especially confusing with decorator syntax like @mcp.tool.

The fix checks whether a VariableName node is preceded by a . sibling in the syntax tree, and if so, skips it.

Reactive variable highlighting was incorrectly decorating property names
when they matched a known variable. For example, given variables `mcp`
and `tool`, the expression `mcp.tool` would highlight both `mcp` and
`tool`, even though `tool` after the dot is a property access, not a
variable reference. This was especially confusing with decorator syntax
like `@mcp.tool`.

The fix checks whether a `VariableName` node is preceded by a `.`
sibling in the syntax tree, and if so, skips it.
@manzt manzt requested a review from Light2Dark as a code owner March 17, 2026 00:15
Copilot AI review requested due to automatic review settings March 17, 2026 00:15
@vercel
Copy link

vercel bot commented Mar 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
marimo-docs Ready Ready Preview, Comment Mar 17, 2026 0:17am

Request Review

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refines the reactive-reference analyzer used by the CodeMirror integration to avoid highlighting reactive variables when a matching identifier is used as an attribute/property name (e.g. the tool part of mcp.tool or @mcp.tool).

Changes:

  • Add an isPropertyAccess() check to exclude VariableName nodes that are preceded by a . token from reactive highlighting.
  • Add snapshot tests intended to verify that property/attribute names are not highlighted as reactive references.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
frontend/src/core/codemirror/reactive-references/analyzer.ts Adds isPropertyAccess() and integrates it into shouldHighlightVariable to suppress highlighting of attribute/property identifiers.
frontend/src/core/codemirror/reactive-references/__tests__/analyzer.test.ts Adds tests/snapshots around @mcp.tool to ensure property names aren’t highlighted.

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

Comment on lines +1118 to +1124
test("should not highlight attribute access matching a for-loop variable", () => {
// When `tool` is used as a for-loop variable, `mcp.tool` (attribute access)
// should NOT have `tool` highlighted — it's a property, not a variable reference.
expect(
runHighlight(
["mcp", "client"],
`
@manzt manzt added the bug Something isn't working label Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants