From 70385163e89be0e488b2d84b4dedcd0cb0038c39 Mon Sep 17 00:00:00 2001 From: Alex Lachance Date: Mon, 14 Sep 2026 07:33:49 +0000 Subject: [PATCH] python: Fix at sign decorator highlighting conflict with matrix multiplication at sign operator (#58077) In the current Python Tree-sitter `highlight.scm`, the `@` used for decorators (`@punctuation.special` rule) is incorrectly overridden by the `@` used for matrix multiplication (`@operator` rule). This PR updates the matrix multiplication highlight query so it only applies in binary operator contexts, and it also removes a duplicate `@punctuation.special` for the `@` decorator. | Before | After | | :---------------------------------------------------------------------------------------------------------------------------------: | :--------------------------------------------------------------------------------------------------------------------------------: | | image| image| Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [ ] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - Fix Python at sign decorator highlighting conflict with matrix multiplication at sign operator --------- Co-authored-by: Finn Evers --- crates/grammars/src/python/highlights.scm | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/crates/grammars/src/python/highlights.scm b/crates/grammars/src/python/highlights.scm index 7641cef117..cf2fb39762 100644 --- a/crates/grammars/src/python/highlights.scm +++ b/crates/grammars/src/python/highlights.scm @@ -46,18 +46,17 @@ function: (identifier) @function.call) (decorator - "@" @punctuation.special) - -(decorator - "@" @punctuation.special + "@" @function.decorator [ (identifier) @function.decorator (attribute + object: (identifier) @function.decorator attribute: (identifier) @function.decorator) (call function: (identifier) @function.decorator.call) (call (attribute + object: (identifier) @function.decorator.call attribute: (identifier) @function.decorator.call)) ]) @@ -257,7 +256,6 @@ "&" "%" "%=" - "@" "^" "+" "->" @@ -282,6 +280,9 @@ "|=" ] @operator +(binary_operator + operator: "@" @operator) + [ "and" "in" @@ -335,8 +336,9 @@ ] @keyword.definition (decorator - (identifier) @attribute.builtin - (#any-of? @attribute.builtin "classmethod" "staticmethod" "property")) + "@" @attribute.builtin + (identifier) @attribute.builtin @_decorator + (#any-of? @_decorator "classmethod" "staticmethod" "property")) (attribute attribute: (identifier) @attribute.special