Repository navigation
feat(editor): richer JS/TS highlighting for JSDoc and methods - #2971
Merged
Merged
Conversation
Contributor
[Medium impact] The PR appears safe to merge; no new actionable issues were found. SummaryAdds richer JavaScript and TypeScript highlighting:
The three earlier, unnumbered findings are addressed: quoted strings skip escapes, optional defaults ignore quoted brackets, and tests cover JSDoc ranges and edits. No new actionable issues were found. Tests were inspected but not run. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
A["JS/TS language loader"] --> B["javascriptSupport"]
B --> C["Method and property tags"]
B --> D["jsdocWrap"]
D --> E["JSDoc tags, types, names and links"]
C --> F["Theme highlight styles"]
E --> F
Reviews (3) · Last reviewed commit: "fix(themes): colour JS properties apart ..." · Reviewed by Greptile |
…lighting - Tag class and interface method names as function definitions and give method calls, method definitions and function declaration names the function colour in all built-in themes. - Bump @lezer/highlight to 1.2.5, which fixes the precedence of context-specific highlight rules added through parser props. - Leave JSDoc braces and punctuation as comment text, handle escaped quotes in types and quoted brackets in optional defaults, and skip /*** comments like TypeScript does. - Add unit tests for JSDoc and method highlighting.
This comment was marked as outdated.
This comment was marked as outdated.
Themes that reused the function colour for properties made this.foo look like a method call. Give properties the palette's property colour where it has one (Tokyo Night, Catppuccin) and the foreground otherwise, and stop colouring Noctis Lilac property definitions as functions.
…g other languages propertyName is shared by CSS properties, JSON/YAML keys, Go/C++ fields and (through attributeName) HTML attributes, so giving it its own colour moved those away from how VS Code colours them. Restore the themes' propertyName colour and tag JS/TS property names with memberProperty, a sub-tag of propertyName that falls back to it in themes that don't style it. Built-in themes colour it like their VS Code counterparts.
This comment was marked as outdated.
This comment was marked as outdated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes JavaScript/TypeScript highlighting being flatter than in VS Code or Zed:
.js,.jsx,.ts,.tsx) were highlighted as a single comment token. Block tags (@param,@returns, …),{types}, parameter names and{@link}targets now get their own highlight tags, so themes can colour them separately.obj.method()), method definitions (constructor(), class/interface methods) and function declaration names were coloured like plain properties/variables in most built-in themes. They now use each theme's function colour.this.foohad the same colour as method calls. JS/TS property names are now taggedmemberProperty(a sub-tag ofpropertyName, so other themes are unaffected) and coloured like the themes' VS Code counterparts, without changing CSS properties, JSON/YAML keys or other languages.@lezer/highlightto 1.2.5, which fixes context-specific highlight rules (needed for method definitions) being overridden by generic ones.