Skip to content

Commit d8ac1fb

Browse files
Ecmel ErcanEcmel Ercan
authored andcommitted
Implemented id completion
1 parent 1747dc7 commit d8ac1fb

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CSS support in HTML documents.
66

77
- Style tag completion and hover.
88
- Style attribute completion and hover.
9+
- Id attribute completion.
910
- Class attribute completion.
1011
- Scans workspace folder for css files.
1112
- Supports optional resource.json file for fine tuned resource selection.

src/extension.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class StyleServer implements vsc.CompletionItemProvider, vsc.HoverProvider {
102102

103103
class ClassServer implements vsc.CompletionItemProvider {
104104

105-
private regex = [/class=["|']([^"^']*$)/i, /<style[\s\S]*>([\s\S]*)<\/style>/ig];
105+
private regex = [/(class|id)=["|']([^"^']*$)/i, /<style[\s\S]*>([\s\S]*)<\/style>/ig];
106106

107107
provideCompletionItems(document: vsc.TextDocument, position: vsc.Position, token: vsc.CancellationToken): vsc.CompletionList {
108108
let start = new vsc.Position(0, 0);
@@ -129,9 +129,13 @@ class ClassServer implements vsc.CompletionItemProvider {
129129
}
130130
}
131131

132+
let id = false;
133+
if (tag[0].startsWith('id')) {
134+
id = true;
135+
}
132136
let ci: vsc.CompletionItem[] = [];
133137
for (let item in items) {
134-
if (items[item].kind === dot) {
138+
if ((id && items[item].kind === hash) || !id && items[item].kind === dot) {
135139
ci.push(items[item]);
136140
}
137141
}

0 commit comments

Comments
 (0)