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 |
|
:---------------------------------------------------------------------------------------------------------------------------------:
|
:--------------------------------------------------------------------------------------------------------------------------------:
|
| <img width="338" height="1056" alt="image"
src="https://github.com/user-attachments/assets/cdce1556-6f7d-4542-abca-bcb3e11b6629"
/>| <img width="380" height="1057" alt="image"
src="https://github.com/user-attachments/assets/f948413c-ad8a-4ccc-89c1-bbffbe2affda"
/>|


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 <finn@zed.dev>
This commit is contained in:
Alex LachanceandFinn Evers authored and GitHub committed 2026-09-14 07:33:49 +00:00
1 parent abc6b3b357
commit 70385163e8
1 file changed
+9 -7
+9 -7
View File
@@ -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