Skip to content

Duplicate class matches when using custom classRegex #552

@tylersayshi

Description

@tylersayshi

What version of Tailwind CSS IntelliSense are you using?

For example: v0.8.4

What version of Tailwind CSS are you using?

For example: v3.0.15

What package manager are you using?

npm

What operating system are you using?

macOS

Reproduction URL

I can make a repro repo if this is absolutely necessary, but I figured I'd explain it here before making a full repo.

Describe your issue

in settings.json:

"tailwindCSS.experimental.classRegex": [
  "tw`([^`]*)`", // tw`...`
  "ClassName='([^']*)", // prefixClassName='...'
  ["clsx\\(([^)]*)\\)", "(?:'|\"|`)([^']*)(?:'|\"|`)"] // clsx(...)
],

The issue is that when a class string matches multiple regexes, the plugin shows the color preview each time it was detected:

image

My hunch is that if there were a .filter used here to remove matches that have the same start and end it would fix the issue.

I would write a PR to edit this, but I wasn't able to run and debug this project locally

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions