Skip to content

Improve JS/TS/TSX parameter highlighting for destructuring#60767

Merged
ChristopherBiscardi merged 1 commit into
zed-industries:mainfrom
feeiyu:fix_js_function_args_highligh
Jul 12, 2026
Merged

Improve JS/TS/TSX parameter highlighting for destructuring#60767
ChristopherBiscardi merged 1 commit into
zed-industries:mainfrom
feeiyu:fix_js_function_args_highligh

Conversation

@feeiyu

@feeiyu feeiyu commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Objective

Fixes #51967

Destructured JS/TS/TSX parameters with defaults were not highlighted consistently as parameters when using themes that distinguish arguments from variables/properties, such as Catppuccin.

For example, in:

function a({ argument = true }) {}

argument was parsed under a default assignment pattern and did not receive the same @variable.parameter capture as a destructured parameter without a default.

This also affected array binding patterns with defaults, such as:

function b([argument = true]) {}

Solution

Updated the JS/TS/TSX highlight queries to capture destructured parameters with default values as @variable.parameter.

This covers both:

  • Object binding patterns with defaults, such as { argument = true }
  • Array binding patterns with defaults, such as [argument = true]

As a result, destructured parameters are highlighted consistently whether or not they provide a default value.

Testing

  • Verified the highlight query changes for JavaScript/TypeScript destructured parameters with defaults.
  • Tested examples include:
    function a({ argument }) {}
    function a({ argument = true }) {}
    function a({ argument = true }?) {} //optional
    function b([argument]) {}
    function b([argument = true]) {}
    function b([argument = true]?) {} // optional
  • These cases should be easiest to visually confirm with a theme that distinguishes parameters from variables/properties, such as Catppuccin.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content adheres to Zed's UI standards (UX/UI and icon guidelines)
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Showcase

Before this change,
图片

After this change:
图片

Release Notes:

  • Fixed inconsistent syntax highlighting for JS/TS/TSX destructured parameters with default values.

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jul 10, 2026
@zed-community-bot zed-community-bot Bot added the guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions label Jul 10, 2026
@feeiyu feeiyu force-pushed the fix_js_function_args_highligh branch from 61ab294 to d9b02a3 Compare July 10, 2026 17:11

@ChristopherBiscardi ChristopherBiscardi 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.

thanks!

@ChristopherBiscardi ChristopherBiscardi self-assigned this Jul 12, 2026
@ChristopherBiscardi ChristopherBiscardi added this pull request to the merge queue Jul 12, 2026
Merged via the queue into zed-industries:main with commit 5d8459e Jul 12, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Destructured function parameters with defaults don't get parameter syntax highlighting

2 participants