Skip to content

Commit a538790

Browse files
committed
1 parent fd6123a commit a538790

File tree

3 files changed

+54
-3
lines changed

3 files changed

+54
-3
lines changed

src/services/languageFacts.ts

+25-3
Original file line numberDiff line numberDiff line change
@@ -783,20 +783,42 @@ let atDirectiveList: IEntry[];
783783
export function getAtDirectives(): IEntry[] {
784784
if (!atDirectiveList) {
785785
atDirectiveList = [];
786-
for (let i = 0, len = atDirectives.length; i < len; i++) {
786+
for (let i = 0; i < atDirectives.length; i++) {
787787
let rawEntry = atDirectives[i];
788788
atDirectiveList.push(new EntryImpl(rawEntry));
789789
}
790790
}
791791
return atDirectiveList;
792792
}
793793

794+
import { scssAtDirectives } from '../data/scss';
795+
let scssAtDirectiveList: IEntry[];
796+
export function getScssAtDirectives(): IEntry[] {
797+
if (!atDirectiveList) {
798+
atDirectiveList = [];
799+
for (let i = 0; i < atDirectives.length; i++) {
800+
let rawEntry = atDirectives[i];
801+
atDirectiveList.push(new EntryImpl(rawEntry));
802+
}
803+
}
804+
805+
if (!scssAtDirectiveList) {
806+
scssAtDirectiveList = [];
807+
for (let i = 0; i < scssAtDirectives.length; i++) {
808+
let rawEntry = scssAtDirectives[i];
809+
scssAtDirectiveList.push(new EntryImpl(rawEntry));
810+
}
811+
}
812+
813+
return scssAtDirectiveList.concat(atDirectiveList);
814+
}
815+
794816
let pseudoElements = browsers.data.css.pseudoelements;
795817
let pseudoElementList: IEntry[];
796818
export function getPseudoElements(): IEntry[] {
797819
if (!pseudoElementList) {
798820
pseudoElementList = [];
799-
for (let i = 0, len = pseudoElements.length; i < len; i++) {
821+
for (let i = 0; i < pseudoElements.length; i++) {
800822
let rawEntry = pseudoElements[i];
801823
pseudoElementList.push(new EntryImpl(rawEntry));
802824
}
@@ -809,7 +831,7 @@ let pseudoClassesList: IEntry[];
809831
export function getPseudoClasses(): IEntry[] {
810832
if (!pseudoClassesList) {
811833
pseudoClassesList = [];
812-
for (let i = 0, len = pseudoClasses.length; i < len; i++) {
834+
for (let i = 0; i < pseudoClasses.length; i++) {
813835
let rawEntry = pseudoClasses[i];
814836
pseudoClassesList.push(new EntryImpl(rawEntry));
815837
}

src/services/scssCompletion.ts

+14
Original file line numberDiff line numberDiff line change
@@ -191,5 +191,19 @@ export class SCSSCompletion extends CSSCompletion {
191191
return result;
192192
}
193193

194+
public getCompletionForTopLevel(result: CompletionList): CompletionList {
195+
for (let entry of languageFacts.getScssAtDirectives()) {
196+
if (entry.browsers.count > 0) {
197+
result.items.push({
198+
label: entry.name,
199+
textEdit: TextEdit.replace(this.getCompletionRange(null), entry.name),
200+
documentation: languageFacts.getEntryDescription(entry),
201+
kind: CompletionItemKind.Keyword
202+
});
203+
}
204+
}
205+
this.getCompletionsForSelector(null, false, result);
206+
return result;
207+
}
194208
}
195209

src/test/scss/scssCompletion.test.ts

+15
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,21 @@ suite('SCSS - Completions', () => {
8888
{ label: '.foo' }
8989
]
9090
});
91+
testCompletionFor('@', {
92+
items: [
93+
{ label: '@extend' },
94+
{ label: '@at-root' },
95+
{ label: '@debug' },
96+
{ label: '@warn' },
97+
{ label: '@error' },
98+
{ label: '@if' },
99+
{ label: '@for' },
100+
{ label: '@each' },
101+
{ label: '@while' },
102+
{ label: '@mixin' },
103+
{ label: '@include' }
104+
]
105+
});
91106
// issue #250
92107
testCompletionFor('.foo { display: block;|', {
93108
count: 0

0 commit comments

Comments
 (0)