vscode-css-languageservice 5.2.0 → 5.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/README.md +1 -0
- package/lib/esm/beautify/beautify-css.js +57 -15
- package/lib/esm/cssLanguageTypes.d.ts +14 -2
- package/lib/esm/data/webCustomData.js +145 -139
- package/lib/esm/parser/cssParser.js +0 -3
- package/lib/esm/services/cssFormatter.js +33 -14
- package/lib/esm/services/selectorPrinting.js +2 -2
- package/lib/umd/beautify/beautify-css.js +57 -15
- package/lib/umd/cssLanguageTypes.d.ts +14 -2
- package/lib/umd/data/webCustomData.js +145 -139
- package/lib/umd/parser/cssParser.js +0 -3
- package/lib/umd/services/cssFormatter.js +33 -14
- package/lib/umd/services/selectorPrinting.js +2 -2
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
|
|
2
|
+
5.4.0 / 2022-04-01
|
|
3
|
+
==================
|
|
4
|
+
* new formatter settings: `braceStyle`, `preserveNewLines`, `maxPreserveNewLines`, `wrapLineLength`, `indentEmptyLines`
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
5.3.0 / 2022-03-23
|
|
8
|
+
==================
|
|
9
|
+
* renamed `CSSFormatConfiguration.selectorSeparatorNewline` to `CSSFormatConfiguration.newlineBetweenSelectors`
|
|
10
|
+
|
|
2
11
|
5.2.0 / 2022-03-17
|
|
3
12
|
==================
|
|
4
13
|
* new API `LanguageService.format`, based on the the css formatter from JS Beautifier (https://github.com/beautify-web/js-beautify)
|
package/README.md
CHANGED
|
@@ -52,6 +52,7 @@ How can I run and debug the service?
|
|
|
52
52
|
How can I run and debug the service inside an instance of VSCode?
|
|
53
53
|
|
|
54
54
|
- run VSCode out of sources setup as described here: https://github.com/Microsoft/vscode/wiki/How-to-Contribute
|
|
55
|
+
- run `yarn link` in the folder of `vscode-css-languageservice`
|
|
55
56
|
- use `yarn link vscode-css-languageservice` in `vscode/extensions/css-language-features/server` to run VSCode with the latest changes from `vscode-css-languageservice`
|
|
56
57
|
- run VSCode out of source (`vscode/scripts/code.sh|bat`) and open a `.css` file
|
|
57
58
|
- in VSCode window that is open on the `vscode-css-languageservice` sources, run command `Debug: Attach to Node process` and pick the `code-oss` process with the `css-language-features` path
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// copied from js-beautify/js/lib/beautify-css.js
|
|
2
|
-
// version: 1.14.
|
|
2
|
+
// version: 1.14.3
|
|
3
3
|
/* AUTO-GENERATED. DO NOT MODIFY. */
|
|
4
4
|
/*
|
|
5
5
|
|
|
@@ -1002,8 +1002,8 @@ module.exports.Directives = Directives;
|
|
|
1002
1002
|
|
|
1003
1003
|
|
|
1004
1004
|
|
|
1005
|
-
var Beautifier = __webpack_require__(16).Beautifier,
|
|
1006
|
-
Options = __webpack_require__(17).Options;
|
|
1005
|
+
var Beautifier = (__webpack_require__(16).Beautifier),
|
|
1006
|
+
Options = (__webpack_require__(17).Options);
|
|
1007
1007
|
|
|
1008
1008
|
function css_beautify(source_text, options) {
|
|
1009
1009
|
var beautifier = new Beautifier(source_text, options);
|
|
@@ -1050,10 +1050,10 @@ module.exports.defaultOptions = function() {
|
|
|
1050
1050
|
|
|
1051
1051
|
|
|
1052
1052
|
|
|
1053
|
-
var Options = __webpack_require__(17).Options;
|
|
1054
|
-
var Output = __webpack_require__(2).Output;
|
|
1055
|
-
var InputScanner = __webpack_require__(8).InputScanner;
|
|
1056
|
-
var Directives = __webpack_require__(13).Directives;
|
|
1053
|
+
var Options = (__webpack_require__(17).Options);
|
|
1054
|
+
var Output = (__webpack_require__(2).Output);
|
|
1055
|
+
var InputScanner = (__webpack_require__(8).InputScanner);
|
|
1056
|
+
var Directives = (__webpack_require__(13).Directives);
|
|
1057
1057
|
|
|
1058
1058
|
var directives_core = new Directives(/\/\*/, /\*\//);
|
|
1059
1059
|
|
|
@@ -1089,6 +1089,9 @@ function Beautifier(source_text, options) {
|
|
|
1089
1089
|
"@supports": true,
|
|
1090
1090
|
"@document": true
|
|
1091
1091
|
};
|
|
1092
|
+
this.NON_SEMICOLON_NEWLINE_PROPERTY = [
|
|
1093
|
+
"grid-template"
|
|
1094
|
+
];
|
|
1092
1095
|
|
|
1093
1096
|
}
|
|
1094
1097
|
|
|
@@ -1213,7 +1216,9 @@ Beautifier.prototype.beautify = function() {
|
|
|
1213
1216
|
var enteringConditionalGroup = false;
|
|
1214
1217
|
var insideAtExtend = false;
|
|
1215
1218
|
var insideAtImport = false;
|
|
1219
|
+
var insideScssMap = false;
|
|
1216
1220
|
var topCharacter = this._ch;
|
|
1221
|
+
var insideNonSemiColonValues = false;
|
|
1217
1222
|
var whitespace;
|
|
1218
1223
|
var isAfterSpace;
|
|
1219
1224
|
var previous_ch;
|
|
@@ -1265,7 +1270,7 @@ Beautifier.prototype.beautify = function() {
|
|
|
1265
1270
|
|
|
1266
1271
|
// Ensures any new lines following the comment are preserved
|
|
1267
1272
|
this.eatWhitespace(true);
|
|
1268
|
-
} else if (this._ch === '@') {
|
|
1273
|
+
} else if (this._ch === '@' || this._ch === '$') {
|
|
1269
1274
|
this.preserveSingleSpace(isAfterSpace);
|
|
1270
1275
|
|
|
1271
1276
|
// deal with less propery mixins @{...}
|
|
@@ -1336,7 +1341,12 @@ Beautifier.prototype.beautify = function() {
|
|
|
1336
1341
|
this.indent();
|
|
1337
1342
|
this._output.set_indent(this._indentLevel);
|
|
1338
1343
|
} else {
|
|
1339
|
-
|
|
1344
|
+
// inside mixin and first param is object
|
|
1345
|
+
if (previous_ch === '(') {
|
|
1346
|
+
this._output.space_before_token = false;
|
|
1347
|
+
} else if (previous_ch !== ',') {
|
|
1348
|
+
this.indent();
|
|
1349
|
+
}
|
|
1340
1350
|
this.print_string(this._ch);
|
|
1341
1351
|
}
|
|
1342
1352
|
|
|
@@ -1368,7 +1378,21 @@ Beautifier.prototype.beautify = function() {
|
|
|
1368
1378
|
this._output.add_new_line(true);
|
|
1369
1379
|
}
|
|
1370
1380
|
}
|
|
1381
|
+
if (this._input.peek() === ')') {
|
|
1382
|
+
this._output.trim(true);
|
|
1383
|
+
if (this._options.brace_style === "expand") {
|
|
1384
|
+
this._output.add_new_line(true);
|
|
1385
|
+
}
|
|
1386
|
+
}
|
|
1371
1387
|
} else if (this._ch === ":") {
|
|
1388
|
+
|
|
1389
|
+
for (var i = 0; i < this.NON_SEMICOLON_NEWLINE_PROPERTY.length; i++) {
|
|
1390
|
+
if (this._input.lookBack(this.NON_SEMICOLON_NEWLINE_PROPERTY[i])) {
|
|
1391
|
+
insideNonSemiColonValues = true;
|
|
1392
|
+
break;
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1372
1396
|
if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend && parenLevel === 0) {
|
|
1373
1397
|
// 'property: value' delimiter
|
|
1374
1398
|
// which could be in a conditional group query
|
|
@@ -1401,6 +1425,7 @@ Beautifier.prototype.beautify = function() {
|
|
|
1401
1425
|
this.print_string(this._ch + this.eatString(this._ch));
|
|
1402
1426
|
this.eatWhitespace(true);
|
|
1403
1427
|
} else if (this._ch === ';') {
|
|
1428
|
+
insideNonSemiColonValues = false;
|
|
1404
1429
|
if (parenLevel === 0) {
|
|
1405
1430
|
if (insidePropertyValue) {
|
|
1406
1431
|
this.outdent();
|
|
@@ -1442,20 +1467,32 @@ Beautifier.prototype.beautify = function() {
|
|
|
1442
1467
|
} else {
|
|
1443
1468
|
this.preserveSingleSpace(isAfterSpace);
|
|
1444
1469
|
this.print_string(this._ch);
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
this.
|
|
1470
|
+
|
|
1471
|
+
// handle scss/sass map
|
|
1472
|
+
if (insidePropertyValue && previous_ch === "$" && this._options.selector_separator_newline) {
|
|
1473
|
+
this._output.add_new_line();
|
|
1474
|
+
insideScssMap = true;
|
|
1475
|
+
} else {
|
|
1476
|
+
this.eatWhitespace();
|
|
1477
|
+
parenLevel++;
|
|
1478
|
+
this.indent();
|
|
1479
|
+
}
|
|
1448
1480
|
}
|
|
1449
1481
|
} else if (this._ch === ')') {
|
|
1450
1482
|
if (parenLevel) {
|
|
1451
1483
|
parenLevel--;
|
|
1452
1484
|
this.outdent();
|
|
1453
1485
|
}
|
|
1486
|
+
if (insideScssMap && this._input.peek() === ";" && this._options.selector_separator_newline) {
|
|
1487
|
+
insideScssMap = false;
|
|
1488
|
+
this.outdent();
|
|
1489
|
+
this._output.add_new_line();
|
|
1490
|
+
}
|
|
1454
1491
|
this.print_string(this._ch);
|
|
1455
1492
|
} else if (this._ch === ',') {
|
|
1456
1493
|
this.print_string(this._ch);
|
|
1457
1494
|
this.eatWhitespace(true);
|
|
1458
|
-
if (this._options.selector_separator_newline && !insidePropertyValue && parenLevel === 0 && !insideAtImport && !insideAtExtend) {
|
|
1495
|
+
if (this._options.selector_separator_newline && (!insidePropertyValue || insideScssMap) && parenLevel === 0 && !insideAtImport && !insideAtExtend) {
|
|
1459
1496
|
this._output.add_new_line();
|
|
1460
1497
|
} else {
|
|
1461
1498
|
this._output.space_before_token = true;
|
|
@@ -1489,8 +1526,13 @@ Beautifier.prototype.beautify = function() {
|
|
|
1489
1526
|
this.print_string(' ');
|
|
1490
1527
|
this.print_string(this._ch);
|
|
1491
1528
|
} else {
|
|
1492
|
-
|
|
1529
|
+
var preserveAfterSpace = previous_ch === '"' || previous_ch === '\'';
|
|
1530
|
+
this.preserveSingleSpace(preserveAfterSpace || isAfterSpace);
|
|
1493
1531
|
this.print_string(this._ch);
|
|
1532
|
+
|
|
1533
|
+
if (!this._output.just_added_newline() && this._input.peek() === '\n' && insideNonSemiColonValues) {
|
|
1534
|
+
this._output.add_new_line();
|
|
1535
|
+
}
|
|
1494
1536
|
}
|
|
1495
1537
|
}
|
|
1496
1538
|
|
|
@@ -1536,7 +1578,7 @@ module.exports.Beautifier = Beautifier;
|
|
|
1536
1578
|
|
|
1537
1579
|
|
|
1538
1580
|
|
|
1539
|
-
var BaseOptions = __webpack_require__(6).Options;
|
|
1581
|
+
var BaseOptions = (__webpack_require__(6).Options);
|
|
1540
1582
|
|
|
1541
1583
|
function Options(options) {
|
|
1542
1584
|
BaseOptions.call(this, options, 'css');
|
|
@@ -217,10 +217,22 @@ export interface CSSFormatConfiguration {
|
|
|
217
217
|
insertSpaces?: boolean;
|
|
218
218
|
/** end with a newline: Default: false */
|
|
219
219
|
insertFinalNewline?: boolean;
|
|
220
|
-
/** separate selectors with newline
|
|
221
|
-
|
|
220
|
+
/** separate selectors with newline (e.g. "a,\nbr" or "a, br"): Default: true */
|
|
221
|
+
newlineBetweenSelectors?: boolean;
|
|
222
222
|
/** add a new line after every css rule: Default: true */
|
|
223
223
|
newlineBetweenRules?: boolean;
|
|
224
224
|
/** ensure space around selector separators: '>', '+', '~' (e.g. "a>b" -> "a > b"): Default: false */
|
|
225
225
|
spaceAroundSelectorSeparator?: boolean;
|
|
226
|
+
/** put braces on the same line as rules (`collapse`), or put braces on own line, Allman / ANSI style (`expand`). Default `collapse` */
|
|
227
|
+
braceStyle?: 'collapse' | 'expand';
|
|
228
|
+
/** whether existing line breaks before elements should be preserved. Default: true */
|
|
229
|
+
preserveNewLines?: boolean;
|
|
230
|
+
/** maximum number of line breaks to be preserved in one chunk. Default: unlimited */
|
|
231
|
+
maxPreserveNewLines?: number;
|
|
232
|
+
/** maximum amount of characters per line (0/undefined = disabled). Default: disabled. */
|
|
233
|
+
wrapLineLength?: number;
|
|
234
|
+
/** add indenting whitespace to empty lines. Default: false */
|
|
235
|
+
indentEmptyLines?: boolean;
|
|
236
|
+
/** @deprecated Use newlineBetweenSelectors instead*/
|
|
237
|
+
selectorSeparatorNewline?: boolean;
|
|
226
238
|
}
|