Skip to content

Commit 5419418

Browse files
committed
Update React and Solid version
1 parent 1ca4d17 commit 5419418

File tree

2 files changed

+10
-8
lines changed
  • react-package/src/extensions/autocomplete/css
  • solid-package/src/extensions/autocomplete/css

2 files changed

+10
-8
lines changed

react-package/src/extensions/autocomplete/css/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ const cssCompletion = (
5656
variables?: Iterable<string>,
5757
): CompletionSource => {
5858
return (context: CompletionContext, editor: PrismEditor) => {
59+
if (getClosestToken(editor, ".comment,.string", 0, 0, context.pos)) return
60+
5961
let before = context.before
6062
let pos = context.pos
6163
let matcher = editor.extensions.matchBrackets
@@ -67,6 +69,7 @@ const cssCompletion = (
6769

6870
let colonIndex = currentStatement.lastIndexOf(":")
6971
let inPropValue = colonIndex > -1
72+
let inVar = /\bvar\s*\(\s*$/.test(before.slice(0, from))
7073

7174
let setPropCompletion = () => {
7275
options = Array.from(
@@ -75,15 +78,13 @@ const cssCompletion = (
7578
inPropValue
7679
? {
7780
label: name,
78-
insert: inPropValue ? `var(${name})` : name,
81+
insert: inVar ? name : `var(${name})`,
7982
}
8083
: createPropCompletion(name),
8184
)
82-
options!.push(...(inPropValue ? cssValues : getCSSProperties()))
85+
if (!(inPropValue && inVar)) options!.push(...(inPropValue ? cssValues : getCSSProperties()))
8386
}
8487

85-
if (getClosestToken(editor, ".comment,.string", 0, 0, pos)) return
86-
8788
if (getClosestToken(editor, ".tag", 0, 0, pos)) {
8889
inPropValue = inPropValue && !/style\s*=/.test(currentStatement.slice(colonIndex))
8990
setPropCompletion()

solid-package/src/extensions/autocomplete/css/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ const cssCompletion = (
5656
variables?: Iterable<string>,
5757
): CompletionSource => {
5858
return (context: CompletionContext, editor: PrismEditor) => {
59+
if (getClosestToken(editor, ".comment,.string", 0, 0, context.pos)) return
60+
5961
let before = context.before
6062
let pos = context.pos
6163
let matcher = editor.extensions.matchBrackets
@@ -67,6 +69,7 @@ const cssCompletion = (
6769

6870
let colonIndex = currentStatement.lastIndexOf(":")
6971
let inPropValue = colonIndex > -1
72+
let inVar = /\bvar\s*\(\s*$/.test(before.slice(0, from))
7073

7174
let setPropCompletion = () => {
7275
options = Array.from(
@@ -75,15 +78,13 @@ const cssCompletion = (
7578
inPropValue
7679
? {
7780
label: name,
78-
insert: inPropValue ? `var(${name})` : name,
81+
insert: inVar ? name : `var(${name})`,
7982
}
8083
: createPropCompletion(name),
8184
)
82-
options!.push(...(inPropValue ? cssValues : getCSSProperties()))
85+
if (!(inPropValue && inVar)) options!.push(...(inPropValue ? cssValues : getCSSProperties()))
8386
}
8487

85-
if (getClosestToken(editor, ".comment,.string", 0, 0, pos)) return
86-
8788
if (getClosestToken(editor, ".tag", 0, 0, pos)) {
8889
inPropValue = inPropValue && !/style\s*=/.test(currentStatement.slice(colonIndex))
8990
setPropCompletion()

0 commit comments

Comments
 (0)