Skip to content

fix: support CSS completions in nested style tags#3022

Merged
jasonlyu123 merged 3 commits into
sveltejs:masterfrom
tkhs0813:fix-css-completions-nested-style
May 12, 2026
Merged

fix: support CSS completions in nested style tags#3022
jasonlyu123 merged 3 commits into
sveltejs:masterfrom
tkhs0813:fix-css-completions-nested-style

Conversation

@tkhs0813

@tkhs0813 tkhs0813 commented May 11, 2026

Copy link
Copy Markdown
Contributor

fix #2175

Fixes CSS completions and hover for nested <style> tags.

Previously, the CSS plugin used document.styleInfo, which only represents the top-level style tag. As a result, positions inside nested style tags were not treated as being inside a generated CSS document, so completions and hover did not work.

This PR resolves the CSS document based on the current cursor position. If the current position is inside a nested <style> tag, the CSS plugin creates a CSSDocument using that tag's styleInfo.

Changes

  • Add extractStyleTagAtOffset to resolve the style tag at the current position using the HTML AST
  • Allow CSSDocument to be created with a specific styleInfo
  • Use a position-based CSS document for completions and hover
  • Add regression tests for:
    • <svelte:head><style></style></svelte:head>
    • a nested <style> tag

@changeset-bot

changeset-bot Bot commented May 11, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: cf79bd6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte-language-server Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment thread packages/language-server/src/plugins/css/CSSPlugin.ts Outdated
@jasonlyu123 jasonlyu123 merged commit eb3fba7 into sveltejs:master May 12, 2026
3 checks passed
@github-actions github-actions Bot mentioned this pull request May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Intelisense Is Not Working in <svelte:head> Tag

2 participants