Skip to content

@astrojs/language-server: @property in <style> breaks syntax highlighting for all subsequent blocks #16751

@PanRoR

Description

@PanRoR

Astro Info

Astro                    v6.3.3
Vite                     v7.3.3
Node                     v24.15.0
System                   Linux (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

All

Describe the Bug

Package: @astrojs/language-server
Repo: withastro/language-tools

Description

Using @property inside a <style> block causes the language server to incorrectly
tokenize the rest of the .astro file. The closing </style> tag loses its syntax
highlighting, and all subsequent <script> and <style> blocks are highlighted
incorrectly as well.

This does not happen in Zed, which suggests the issue is specific to the
@astrojs/language-server used by the VS Code extension.

Steps to Reproduce

Create an .astro file with the following content:

<script>
  console.log(window);
</script>

<style>
  @property --logo-color {
    syntax: "<color>";
    inherits: false;
    initial-value: #c0ffee;
  }
</style>

<style>
  div {
    background: red;
  }
</style>

<script>
  console.log(window);

  function testFunc() {
        console.log("test");
    }

    testFunc();
</script>

Actual Behavior

  • The closing </style> tag after the @property block loses correct highlighting
  • All subsequent <style> and <script> blocks (both content and tags) are
    incorrectly highlighted
  • Subsequent </style> closing tags are also affected

Environment

  • VS Code version: 1.120
  • Astro VS Code extension (astro-vscode) version: 2.16.14

Additional Context

The issue does not reproduce in Zed editor, indicating this is specific to the
language server's tokenizer/parser, not a general CSS grammar issue.

Confirmed on both Linux and Windows, so this is not OS-specific.

VSCode Picture with at-property:

Image

VSCode Picture without at-property:

Image

What's the expected result?

All <style> and <script> blocks are highlighted correctly regardless of
@property usage.

Link to Minimal Reproducible Example

https://github.com/PanRoR/astro-at-property-highlighting

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P3: minor bugAn edge case that only affects very specific usage (priority)pkg: language-toolsRelated to language-tooling (scope)

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions