Skip to content

Commit

Permalink
feat(autoComplete): vue file :class support
Browse files Browse the repository at this point in the history
  • Loading branch information
loosheng committed Jun 13, 2022
1 parent f2b62e0 commit 117a9f5
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/preset-attributify/src/autocomplete.ts
Expand Up @@ -40,7 +40,7 @@ export const autocompleteExtractorAttributify: AutoCompleteExtractor = {
if (!attrName)
return null

if (attrName === 'class' || attrName === 'className')
if (attrName === 'class' || attrName === 'className' || attrName === ':class')
return null
if (attrValues === undefined) {
return {
Expand Down
2 changes: 1 addition & 1 deletion packages/shared-common/src/index.ts
Expand Up @@ -44,7 +44,7 @@ export function getMatchedPositions(code: string, matched: string[]) {

// hightlight for plain classes
let start = 0
code.split(/[\s"';<>]/g).forEach((i) => {
code.split(/[\s"'`;<>]/g).forEach((i) => {
const end = start + i.length
if (plain.has(i))
result.push([start, end, i])
Expand Down
3 changes: 3 additions & 0 deletions test/autocomplete-utils.test.ts
Expand Up @@ -9,6 +9,9 @@ describe('searchUsageBoundary', () => {
expect(searchUsageBoundary('<div class="p-1 p-2', 14).content)
.toMatchInlineSnapshot('"p-1"')

expect(searchUsageBoundary('<div :class="`p-1 p-2', 16).content)
.toMatchInlineSnapshot('"p-1"')

expect(searchUsageBoundary('<div p-1 p-2>', 10).content)
.toMatchInlineSnapshot('"p-2"')

Expand Down

0 comments on commit 117a9f5

Please sign in to comment.