Skip to content

Commit 1747dc7

Browse files
Ecmel ErcanEcmel Ercan
authored andcommitted
Begin id completion
1 parent 99dfa47 commit 1747dc7

File tree

5 files changed

+60
-16
lines changed

5 files changed

+60
-16
lines changed

src/extension.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import * as path from 'path';
1010

1111
let service = css.getCSSLanguageService();
1212
let map: { [index: string]: vsc.CompletionItem[]; } = {};
13-
let regex = /[.]([\w-]+)/g;
13+
let regex = /[\.\#]([\w-]+)/g;
14+
let dot = vsc.CompletionItemKind.Class;
15+
let hash = vsc.CompletionItemKind.Reference;
1416

1517
class Snippet {
1618

@@ -129,7 +131,9 @@ class ClassServer implements vsc.CompletionItemProvider {
129131

130132
let ci: vsc.CompletionItem[] = [];
131133
for (let item in items) {
132-
ci.push(items[item]);
134+
if (items[item].kind === dot) {
135+
ci.push(items[item]);
136+
}
133137
}
134138
return new vsc.CompletionList(ci);
135139
}
@@ -150,6 +154,7 @@ function pushSymbols(key: string, symbols: lst.SymbolInformation[]): void {
150154
let symbol;
151155
while (symbol = regex.exec(symbols[i].name)) {
152156
let item = new vsc.CompletionItem(symbol[1]);
157+
item.kind = symbol[0].startsWith('.') ? dot : hash;
153158
ci.push(item);
154159
}
155160
}

test/test .cshtml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,21 @@
1010
.test2 .test3 {
1111
color: gray;
1212
}
13+
14+
#test4 {
15+
color: red;
16+
}
1317
</style>
1418
</head>
1519

1620
<body>
17-
<a href="#" style="color: white; background-color: ghostwhite;" class="external">TEST</a>
18-
<a href="#" style="
21+
<a href="#" id="external-test" style="color: white; background-color: ghostwhite;" class="external">TEST</a>
22+
<a href="#"
23+
id="test4"
24+
style="
1925
color: white;
20-
background-color: ghostwhite;
21-
" class="
26+
background-color: ghostwhite;"
27+
class="
2228
external
2329
test
2430
">TEST</a>

test/test.blade.php

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,33 @@
11
<html>
2+
23
<head>
3-
<style>
4-
.test {
5-
color: red;
6-
}
7-
</style>
4+
<style>
5+
.test {
6+
color: red;
7+
background-color: blue;
8+
}
9+
10+
.test2 .test3 {
11+
color: gray;
12+
}
13+
14+
#test4 {
15+
color: red;
16+
}
17+
</style>
818
</head>
9-
<body class="external test">
19+
20+
<body>
21+
<a href="#" id="external-test" style="color: white; background-color: ghostwhite;" class="external">TEST</a>
22+
<a href="#"
23+
id="test4"
24+
style="
25+
color: white;
26+
background-color: ghostwhite;"
27+
class="
28+
external
29+
test
30+
">TEST</a>
1031
</body>
32+
1133
</html>

test/test.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
.external {
22
color: red;
33
background-color: blue;
4+
}
5+
6+
#external-test {
7+
color: red;
8+
background-color: blue;
49
}

test/test.html

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,21 @@
1010
.test2 .test3 {
1111
color: gray;
1212
}
13+
14+
#test4 {
15+
color: red;
16+
}
1317
</style>
1418
</head>
1519

1620
<body>
17-
<a href="#" style="color: white; background-color: ghostwhite;" class="external">TEST</a>
18-
<a href="#" style="
21+
<a href="#" id="external-test" style="color: white; background-color: ghostwhite;" class="external">TEST</a>
22+
<a href="#"
23+
id="test4"
24+
style="
1925
color: white;
20-
background-color: ghostwhite;
21-
" class="
26+
background-color: ghostwhite;"
27+
class="
2228
external
2329
test
2430
">TEST</a>

0 commit comments

Comments
 (0)