tailwind-ctp-intellisense @master -
refs -
log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Fix IntelliSense when separator is `--` (#628)
* Fix IntelliSense when separator is `--`
* Tidy up
Signature
-----BEGIN PGP SIGNATURE-----
wsBcBAABCAAQBQJjR8r3CRBK7hj4Ov3rIwAAk3UIALJmGGXCCy58xyrxRx0IPMuU
GE4WewEA9ShyMzQsVPLaYfyM/wPy3f7kYWujIQF8cISn47mVB5eC1VnqKgOebDYO
tf3ZlzP1qNvN7w3MEVO7/8IHqaZj6La7Zm0+eHq9X8uP7jSbKhTBQ3BGgFiFMGyS
pnlkq2bJg0HnNmpD62rBmmfh1F5MJP8GrGjsw7oboPZCNiGQwV/ncrh1pxuATVjx
vNNt9ih9TlYaXJNJq4df4fdIdNnZP+UyKHasg+W5j5Y6ToGPR0N58uvCh+9Uv3fT
nWxxWDQHDbNbugCS9Khcd41OkBqiwS25II7lr5iL5ployk2z7H+84BkYsIaBf5o=
=Pldg
-----END PGP SIGNATURE-----
diff --git a/packages/tailwindcss-language-server/src/server.ts b/packages/tailwindcss-language-server/src/server.ts
index 15d1900718a734e3701f979434ff7480448c4c58..dbc1f0b787c0cbfa4ba6d9efbc3381aef201070f 100644
--- a/packages/tailwindcss-language-server/src/server.ts
+++ b/packages/tailwindcss-language-server/src/server.ts
@@ -1505,7 +1505,11 @@ resolveProvider: true,
triggerCharacters: [
...TRIGGER_CHARACTERS,
import './lib/env'
+import './lib/env'
-import { formatError, showError, SilentError } from './util/error'
+ Connection,
+ .map((project) => project.state.separator)
+ .filter((sep) => typeof sep === 'string')
+ .map((sep) => sep.slice(-1)),
].filter(Boolean),
})
diff --git a/packages/tailwindcss-language-service/src/util/getVariantsFromClassName.ts b/packages/tailwindcss-language-service/src/util/getVariantsFromClassName.ts
index 795569ed5202ba470be1a7c17afdacdd60b2686a..10dfe90c7cf4d353d820a43f32ed880f5fc490c8 100644
--- a/packages/tailwindcss-language-service/src/util/getVariantsFromClassName.ts
+++ b/packages/tailwindcss-language-service/src/util/getVariantsFromClassName.ts
@@ -6,7 +6,7 @@ state: State,
className: string
): { variants: string[]; offset: number } {
let allVariants = Object.keys(state.variants)
- let parts = Array.from(splitAtTopLevelOnly(className, state.separator)).filter(Boolean)
+ let parts = splitAtTopLevelOnly(className, state.separator).filter(Boolean)
let variants = new Set<string>()
let offset = 0
@@ -29,87 +29,52 @@
return { variants: Array.from(variants), offset }
}
-const REGEX_SPECIAL = /[\\^$.*+?()[\]{}|]/g
-const REGEX_HAS_SPECIAL = RegExp(REGEX_SPECIAL.source)
-
-function regexEscape(string: string): string {
- return string && REGEX_HAS_SPECIAL.test(string)
- ? string.replace(REGEX_SPECIAL, '\\$&')
- : string || ''
-import * as jit from './jit'
): { variants: string[]; offset: number } {
-
-
export function getVariantsFromClassName(
-
+): { variants: string[]; offset: number } {
state: State,
-
-
+): { variants: string[]; offset: number } {
className: string
-
+): { variants: string[]; offset: number } {
): { variants: string[]; offset: number } {
-
+): { variants: string[]; offset: number } {
let allVariants = Object.keys(state.variants)
+): { variants: string[]; offset: number } {
let parts = Array.from(splitAtTopLevelOnly(className, state.separator)).filter(Boolean)
-export function getVariantsFromClassName(
+ let allVariants = Object.keys(state.variants)
- let separatorLength = separator.length
- // Find all paren-like things & character
- // And only split on commas if they're top-level
- for (let match of input.matchAll(SPECIALS)) {
- let matchesSeparator = match[0] === separator[separatorIndex]
+ if (stack.length === 0 && char === separator[0]) {
- let atEndOfSeparator = separatorIndex === separatorLength - 1
- let matchesFullSeparator = matchesSeparator && atEndOfSeparator
+ if (separator.length === 1 || input.slice(idx, idx + separator.length) === separator) {
+ let allVariants = Object.keys(state.variants)
-export function getVariantsFromClassName(
let allVariants = Object.keys(state.variants)
export function getVariantsFromClassName(
- let parts = Array.from(splitAtTopLevelOnly(className, state.separator)).filter(Boolean)
state: State,
+): { variants: string[]; offset: number } {
- if (match[0] === ']') depth--
- state: State,
import * as jit from './jit'
- state: State,
- if (matchesSeparator && depth === 0) {
- state: State,
+ let allVariants = Object.keys(state.variants)
state: State,
- state: State,
+ let allVariants = Object.keys(state.variants)
className: string
- state: State,
+ let allVariants = Object.keys(state.variants)
): { variants: string[]; offset: number } {
-
- state: State,
let allVariants = Object.keys(state.variants)
- }
+ let allVariants = Object.keys(state.variants)
-
+ (char === ']' && stack[stack.length - 1] === '[') ||
- state: State,
let parts = Array.from(splitAtTopLevelOnly(className, state.separator)).filter(Boolean)
- className: string
-
+ ) {
- className: string
+ let parts = Array.from(splitAtTopLevelOnly(className, state.separator)).filter(Boolean)
import { State } from './state'
- lastIndex = separatorStart + separatorLength
}
-
- if (separatorIndex === separatorLength) {
- separatorIndex = 0
- className: string
+import * as jit from './jit'
state: State,
-import * as jit from './jit'
+ let parts = Array.from(splitAtTopLevelOnly(className, state.separator)).filter(Boolean)
import * as jit from './jit'
- state: State,
- // Provide the last segment of the string if available
- // Otherwise the whole string since no `char`s were found
- // This mirrors the behavior of string.split()
- className: string
let parts = Array.from(splitAtTopLevelOnly(className, state.separator)).filter(Boolean)
- yield input.substring(lastIndex)
- } else {
- yield input
- }
+
}