Skip to content

scuffed @custom-variant behavior #1211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tizu69 opened this issue Feb 16, 2025 · 5 comments · Fixed by #1212
Closed

scuffed @custom-variant behavior #1211

tizu69 opened this issue Feb 16, 2025 · 5 comments · Fixed by #1212
Assignees
Labels
bug Something isn't working

Comments

@tizu69
Copy link
Contributor

tizu69 commented Feb 16, 2025

Registering a v4 custom-variant with a nested (pseudo-)selector causes "at-rule or selector expected". It compiles just fine.

@custom-variant poi {
	&:hover,
	&:focus-visible {
		@slot;
	}
}

Image

The last 2 errors go away on removing the @slots ;. However, this is not a viable option, as Prettier adds it back.


Oddly enough, it seems to replace this with... whatever this mess is.

Image


Image

This happens because the Regex matches up to a ;: (\s+[^;]+). I'm not sure what the point of this is.
There is another matcher that uses { right below, but it never gets called, as the matcher with the ; already
replaces everything up to the slot semicolon.

Removing it seems to have done the trick. All tests pass with this change.


Image

... now this throws. Even if I restore the original extension. lovely.

The space was added by Prettier, but this also happens without it. Adding other spaces restores it to [ *], so my PR allows a space before *.

It seems like it doesn't like *. Replacing it with _ in the virtual document works fine. All tests pass with this change.


I'd like to work on this. I'll follow up with a PR in a bit.

@gustavopch
Copy link

The problem also happens with this snippet from the documentation.

@custom-variant supports-grid {
  @supports (display: grid) {
    @slot;
  }
}
Image

@tizu69
Copy link
Contributor Author

tizu69 commented Feb 16, 2025

The problem also happens with this snippet from the documentation

@gustavopch is this with the fixes applied, or original extension?

@tizu69 tizu69 changed the title the lsp is scuffed scuffed @custom-variant behavior Feb 16, 2025
@gustavopch
Copy link

The original extension. Didn't try your patch.

@thecrypticace thecrypticace self-assigned this Feb 17, 2025
@thecrypticace thecrypticace added the bug Something isn't working label Feb 17, 2025
@tlgreg
Copy link

tlgreg commented Feb 17, 2025

It has been happening since 0.14.4, seems like the shorthand fix might have broken the long form. #1183

@thecrypticace
Copy link
Contributor

yep it did — sorry! Obviously I need to add automated tests for the css language mode this week.

Gonna push a fix out today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants