Skip to content
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

fix(language-server): support escape hatched colors #73

Merged
merged 1 commit into from
Feb 24, 2025

Conversation

cgatian
Copy link
Contributor

@cgatian cgatian commented Feb 24, 2025

allow escape hatch brackets when resolving a color token
fix issue where regex with global flag retains state see: https://stackoverflow.com/a/1520853/684869

Closes #38

📝 Description

Add a brief description

⛳️ Current behavior (updates)

Escaped hatched colors color: [red] do not show inline hints

🚀 New behavior

Escape hatched colors show color value preview

image

💣 Is this a breaking change (Yes/No):

No

📝 Additional Information

allow escape hatch brackets when resolving a color token
fix issue where regex with global flag retains state see: https://stackoverflow.com/a/1520853/684869

Fixes chakra-ui#38
Copy link

changeset-bot bot commented Feb 24, 2025

🦋 Changeset detected

Latest commit: 3101b48

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

This PR includes changesets to release 1 package
Name Type
@pandacss/language-server Minor

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

@@ -45,14 +45,42 @@ test('CSS var', () => {
test('token reference with curly braces', () => {
const ctx = createContext()
expect(getTokenFromPropValue(ctx, 'border', '{colors.gray.300}')).toMatchInlineSnapshot(`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@astahmer this test was broken due to the backing regex maintaining state across invocation due to the g flag being used on the expression. Removed the /g flags from the expression.

see: https://stackoverflow.com/a/1520853/684869


const removeEscapeHatch = (value: string) => {
if (ESCAPE_HATCHED.test(value)) {
return value.match(ESCAPE_HATCHED)?.[2] as string
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it matches, the second group should always be available

[#fff]
0: [#fff]
1: [
2: #fff
3: ]

@astahmer astahmer self-requested a review February 24, 2025 14:49
@astahmer astahmer merged commit 01496c6 into chakra-ui:main Feb 24, 2025
3 checks passed
@cgatian cgatian mentioned this pull request Feb 24, 2025
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.

Arbitrary selectors
2 participants