Merge branch 'master' into diagnostics

master
Brad Cornes 2020-06-12 16:20:32 +01:00
commit eb0b8e55be
10 changed files with 18 additions and 8 deletions

View File

@ -8,3 +8,4 @@ contributing.md
node_modules/** node_modules/**
src/** src/**
tests/** tests/**
img/**

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
img/css.gif 100755

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
img/html-hover.gif 100755

Binary file not shown.

After

Width:  |  Height:  |  Size: 592 KiB

BIN
img/html.gif 100755

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 MiB

2
package-lock.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "vscode-tailwindcss", "name": "vscode-tailwindcss",
"version": "0.3.0", "version": "0.3.1",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {

View File

@ -5,7 +5,7 @@
"preview": true, "preview": true,
"author": "Brad Cornes <hello@bradley.dev>", "author": "Brad Cornes <hello@bradley.dev>",
"license": "MIT", "license": "MIT",
"version": "0.3.0", "version": "0.3.1",
"homepage": "https://github.com/bradlc/vscode-tailwindcss", "homepage": "https://github.com/bradlc/vscode-tailwindcss",
"bugs": { "bugs": {
"url": "https://github.com/bradlc/vscode-tailwindcss/issues", "url": "https://github.com/bradlc/vscode-tailwindcss/issues",
@ -60,12 +60,15 @@
"tailwindCSS.emmetCompletions": { "tailwindCSS.emmetCompletions": {
"type": "boolean", "type": "boolean",
"default": false, "default": false,
"description": "Enable class name completions when using Emmet-style syntax, for example `div.bg-red-500.uppercase`." "markdownDescription": "Enable class name completions when using Emmet-style syntax, for example `div.bg-red-500.uppercase`"
}, },
"tailwindCSS.includeLanguages": { "tailwindCSS.includeLanguages": {
"type": "object", "type": "object",
"additionalProperties": {
"type": "string"
},
"default": {}, "default": {},
"description": "Enable features in languages that are not supported by default. Add a mapping here between the new language and an already supported language.\n E.g.: `{\"plaintext\": \"html\"}`" "markdownDescription": "Enable features in languages that are not supported by default. Add a mapping here between the new language and an already supported language.\n E.g.: `{\"plaintext\": \"html\"}`"
} }
} }
} }

View File

@ -126,7 +126,7 @@ function provideClassAttributeCompletions(
end: position, end: position,
}) })
const match = findLast(/[\s:]class(?:Name)?=['"`{]/gi, str) const match = findLast(/(?:\b|:)class(?:Name)?=['"`{]/gi, str)
if (match === null) { if (match === null) {
return null return null

View File

@ -5,8 +5,11 @@ import { isCssContext, isCssDoc } from './css'
import { isHtmlContext, isHtmlDoc, isSvelteDoc, isVueDoc } from './html' import { isHtmlContext, isHtmlDoc, isSvelteDoc, isVueDoc } from './html'
import { isWithinRange } from './isWithinRange' import { isWithinRange } from './isWithinRange'
import { isJsContext, isJsDoc } from './js' import { isJsContext, isJsDoc } from './js'
import { getClassAttributeLexer } from './lexers'
import { flatten } from '../../util/array' import { flatten } from '../../util/array'
import {
getClassAttributeLexer,
getComputedClassAttributeLexer,
} from './lexers'
export function findAll(re: RegExp, str: string): RegExpMatchArray[] { export function findAll(re: RegExp, str: string): RegExpMatchArray[] {
let match: RegExpMatchArray let match: RegExpMatchArray
@ -111,13 +114,16 @@ export function findClassListsInHtmlRange(
range?: Range range?: Range
): DocumentClassList[] { ): DocumentClassList[] {
const text = doc.getText(range) const text = doc.getText(range)
const matches = findAll(/[\s:]class(?:Name)?=['"`{]/g, text) const matches = findAll(/(?:\b|:)class(?:Name)?=['"`{]/g, text)
const result: DocumentClassList[] = [] const result: DocumentClassList[] = []
matches.forEach((match) => { matches.forEach((match) => {
const subtext = text.substr(match.index + match[0].length - 1, 200) const subtext = text.substr(match.index + match[0].length - 1, 200)
let lexer = getClassAttributeLexer() let lexer =
match[0][0] === ':'
? getComputedClassAttributeLexer()
: getClassAttributeLexer()
lexer.reset(subtext) lexer.reset(subtext)
let classLists: { value: string; offset: number }[] = [] let classLists: { value: string; offset: number }[] = []