Skip to content

Commit 3dd6d72

Browse files
Ecmel ErcanEcmel Ercan
authored andcommitted
Zen Coding support
1 parent 57b448d commit 3dd6d72

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ CSS support for HTML documents.
88
- Style attribute completion and hover.
99
- Id attribute completion.
1010
- Class attribute completion.
11+
- Supports Zen Coding for id and class attributes
1112
- Scans workspace folder for css files.
1213
- Supports optional resource.json file for fine tuned resource selection.
1314
- Uses [vscode-css-languageservice](https://github.com/Microsoft/vscode-css-languageservice).

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "vscode-html-css",
33
"displayName": "HTML CSS Support",
4-
"description": "CSS support in HTML documents",
4+
"description": "CSS support for HTML documents",
55
"version": "0.0.21",
66
"publisher": "ecmel",
77
"license": "MIT",

src/extension.ts

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

103103
class ClassServer implements vsc.CompletionItemProvider {
104104

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

107107
provideCompletionItems(document: vsc.TextDocument, position: vsc.Position, token: vsc.CancellationToken): vsc.CompletionList {
108108
let start = new vsc.Position(0, 0);
109109
let range = new vsc.Range(start, position);
110110
let text = document.getText(range);
111111

112112
let tag = this.regex[0].exec(text);
113+
if (!tag) {
114+
tag = this.regex[2].exec(text);
115+
}
113116
if (tag) {
114117
let internal: lst.SymbolInformation[] = [];
115118
let style;
@@ -129,7 +132,7 @@ class ClassServer implements vsc.CompletionItemProvider {
129132
}
130133
}
131134

132-
let id = tag[0].startsWith('id');
135+
let id = tag[0].startsWith('id') || tag[0].startsWith('#');
133136
let ci: vsc.CompletionItem[] = [];
134137
for (let item in items) {
135138
if ((id && items[item].kind === hash) || !id && items[item].kind === dot) {

0 commit comments

Comments
 (0)