Skip to content

Commit bb90af8

Browse files
committed
Updated settings
1 parent bd5a8da commit bb90af8

File tree

3 files changed

+39
-26
lines changed

3 files changed

+39
-26
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
All notable changes to the extension will be documented in this file.
44

5+
## [1.6.0] - 2020-12-29
6+
7+
- Updated settings.
8+
59
## [1.5.0] - 2020-12-28
610

711
- Added `css.validation` setting.

package.json

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-html-css",
33
"displayName": "HTML CSS Support",
44
"description": "CSS Intellisense for HTML",
5-
"version": "1.5.0",
5+
"version": "1.6.0",
66
"publisher": "ecmel",
77
"license": "MIT",
88
"homepage": "https://github.com/ecmel/vscode-html-css",
@@ -38,26 +38,35 @@
3838
"properties": {
3939
"css.enabledLanguages": {
4040
"type": "array",
41-
"description": "A list of languages where suggestions are desired.",
41+
"scope": "application",
42+
"description": "List of languages where suggestions are desired.",
4243
"default": [
4344
"html"
44-
],
45-
"scope": "application"
46-
},
47-
"css.styleSheets": {
48-
"type": "array",
49-
"default": [],
50-
"description": "A list of local or remote style sheets for suggestions.",
51-
"scope": "resource"
45+
]
5246
},
5347
"css.validation": {
5448
"type": "object",
55-
"default": {
56-
"id": false,
57-
"class": true
58-
},
59-
"description": "Choose selectors for validation.",
60-
"scope": "resource"
49+
"scope": "resource",
50+
"description": "Map of selectors to validate.",
51+
"default": {},
52+
"properties": {
53+
"id": {
54+
"type": "boolean",
55+
"description": "Whether to validate 'id' selectors.",
56+
"default": false
57+
},
58+
"class": {
59+
"type": "boolean",
60+
"description": "Whether to validate 'class' selectors.",
61+
"default": true
62+
}
63+
}
64+
},
65+
"css.styleSheets": {
66+
"type": "array",
67+
"scope": "resource",
68+
"description": "List of local or remote style sheets for suggestions.",
69+
"default": []
6170
}
6271
}
6372
}

src/completion.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@ import {
2020
workspace
2121
} from "vscode";
2222

23-
type Validation = {
24-
id: boolean;
25-
class: boolean;
26-
};
27-
2823
export class SelectorCompletionItemProvider implements CompletionItemProvider, Disposable {
2924

3025
readonly none = "__!NONE!__";
@@ -68,8 +63,12 @@ export class SelectorCompletionItemProvider implements CompletionItemProvider, D
6863
return workspace.getConfiguration("css", uri).get<string[]>("styleSheets", []);
6964
}
7065

71-
getValidation(uri: Uri): Validation {
72-
return workspace.getConfiguration("css", uri).get<Validation>("validation", { id: false, class: true });
66+
isValidateId(uri: Uri): boolean {
67+
return workspace.getConfiguration("css", uri).get<boolean>("validation.id", false);
68+
}
69+
70+
isValidateClass(uri: Uri): boolean {
71+
return workspace.getConfiguration("css", uri).get<boolean>("validation.class", true);
7372
}
7473

7574
getRelativePath(uri: Uri, spec: string, ext?: string): string {
@@ -302,7 +301,8 @@ export class SelectorCompletionItemProvider implements CompletionItemProvider, D
302301
this.findAll(uri, text).then(sets => {
303302
const ids = new Set<string>();
304303
const classes = new Set<string>();
305-
const validation = this.getValidation(uri);
304+
const isValidateId = this.isValidateId(uri);
305+
const isValidateClass = this.isValidateClass(uri);
306306

307307
sets.forEach(set => set.forEach(key => this.getItems(key)?.forEach((v, k) => {
308308
if (v.kind === CompletionItemKind.Value) {
@@ -332,13 +332,13 @@ export class SelectorCompletionItemProvider implements CompletionItemProvider, D
332332
const start = document.positionAt(anchor - value[1].length);
333333

334334
if (attribute[1] === "id") {
335-
if (validation.id && !ids.has(value[1])) {
335+
if (isValidateId && !ids.has(value[1])) {
336336
diagnostics.push(new Diagnostic(new Range(start, end),
337337
`CSS id selector '${value[1]}' not found.`,
338338
DiagnosticSeverity.Information));
339339
}
340340
} else {
341-
if (validation.class && !classes.has(value[1])) {
341+
if (isValidateClass && !classes.has(value[1])) {
342342
diagnostics.push(new Diagnostic(new Range(start, end),
343343
`CSS class selector '${value[1]}' not found.`,
344344
DiagnosticSeverity.Warning));

0 commit comments

Comments
 (0)