Skip to content

Commit 18b3bdf

Browse files
committed
Fixes
1 parent 63f96f9 commit 18b3bdf

File tree

1 file changed

+24
-26
lines changed

1 file changed

+24
-26
lines changed

src/completion.ts

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -108,44 +108,42 @@ export class SelectorCompletionItemProvider implements CompletionItemProvider, D
108108
}
109109

110110
async fetchLocal(key: string, uri: Uri): Promise<void> {
111-
if (!this.cache.has(key)) {
112-
const items = new Map<string, CompletionItem>();
113-
const file = Uri.file(this.getRelativePath(uri, key));
114-
115-
try {
116-
const content = await workspace.fs.readFile(file);
117-
this.parseTextToItems(content.toString(), items);
118-
} catch (error) {
119-
}
111+
const items = new Map<string, CompletionItem>();
112+
const file = Uri.file(this.getRelativePath(uri, key));
120113

121-
this.cache.set(key, items);
122-
this.watchFile(file, e => this.cache.delete(key));
114+
try {
115+
const content = await workspace.fs.readFile(file);
116+
this.parseTextToItems(content.toString(), items);
117+
} catch (error) {
123118
}
119+
120+
this.cache.set(key, items);
121+
this.watchFile(file, e => this.cache.delete(key));
124122
}
125123

126124
async fetchRemote(key: string): Promise<void> {
127-
if (!this.cache.has(key)) {
128-
const items = new Map<string, CompletionItem>();
125+
const items = new Map<string, CompletionItem>();
129126

130-
try {
131-
const res = await fetch(key);
127+
try {
128+
const res = await fetch(key);
132129

133-
if (res.ok) {
134-
const text = await res.text();
135-
this.parseTextToItems(text, items);
136-
}
137-
} catch (error) {
130+
if (res.ok) {
131+
const text = await res.text();
132+
this.parseTextToItems(text, items);
138133
}
139-
140-
this.cache.set(key, items);
134+
} catch (error) {
141135
}
136+
137+
this.cache.set(key, items);
142138
}
143139

144140
async fetchStyleSheet(key: string, uri: Uri): Promise<void> {
145-
if (this.isRemote.test(key)) {
146-
await this.fetchRemote(key);
147-
} else {
148-
await this.fetchLocal(key, uri);
141+
if (!this.cache.has(key)) {
142+
if (this.isRemote.test(key)) {
143+
await this.fetchRemote(key);
144+
} else {
145+
await this.fetchLocal(key, uri);
146+
}
149147
}
150148
}
151149

0 commit comments

Comments
 (0)