Skip to content

Commit 17e7ca9

Browse files
committed
Fixes
1 parent e671812 commit 17e7ca9

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/completion.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,13 @@ export class SelectorCompletionItemProvider implements CompletionItemProvider, D
166166
async findLinks(uri: Uri, keys: Set<string>, text: string): Promise<void> {
167167
const findLinks = /<link([^>]+)>/gi;
168168

169-
let link;
169+
let link, rel, href;
170170

171171
while ((link = findLinks.exec(text)) !== null) {
172-
const rel = this.findLinkRel.exec(link[1]);
172+
rel = this.findLinkRel.exec(link[1]);
173173

174174
if (rel && rel[2] === "stylesheet") {
175-
const href = this.findLinkHref.exec(link[1]);
175+
href = this.findLinkHref.exec(link[1]);
176176

177177
if (href) {
178178
keys.add(await this.fetch(uri, href[2]));
@@ -238,22 +238,20 @@ export class SelectorCompletionItemProvider implements CompletionItemProvider, D
238238
const diagnostics: Diagnostic[] = [];
239239
const findAttribute = /(id|class|className)\s*=\s*("|')(.*?)\2/gsi;
240240

241-
let attribute;
241+
let attribute, offset, findSelector, value, anchor, end, start;
242242

243243
while ((attribute = findAttribute.exec(text)) !== null) {
244-
const offset = findAttribute.lastIndex
244+
offset = findAttribute.lastIndex
245245
- attribute[3].length
246246
+ attribute[3].indexOf(attribute[2]);
247247

248-
const findSelector = /([^(\[{}\])\s]+)(?![^(\[{]*[}\])])/gi;
249-
250-
let value;
248+
findSelector = /([^(\[{}\])\s]+)(?![^(\[{]*[}\])])/gi;
251249

252250
while ((value = findSelector.exec(attribute[3])) !== null) {
253251
if (!(attribute[1] === "id" ? context.ids : context.classes).has(value[1])) {
254-
const anchor = findSelector.lastIndex + offset;
255-
const end = document.positionAt(anchor);
256-
const start = document.positionAt(anchor - value[1].length);
252+
anchor = findSelector.lastIndex + offset;
253+
end = document.positionAt(anchor);
254+
start = document.positionAt(anchor - value[1].length);
257255

258256
diagnostics.push(new Diagnostic(new Range(start, end),
259257
`CSS selector '${value[1]}' not found.`,

0 commit comments

Comments
 (0)