vscode-css-languageservice 5.4.1 → 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/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
2
+ // version: 1.14.3
3
3
  /* AUTO-GENERATED. DO NOT MODIFY. */
4
4
  /*
5
5
 
@@ -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
- this.indent();
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
- this.eatWhitespace();
1446
- parenLevel++;
1447
- this.indent();
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
- this.preserveSingleSpace(isAfterSpace);
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
 
@@ -1353,9 +1353,6 @@ var Parser = /** @class */ (function () {
1353
1353
  }
1354
1354
  this.consumeToken();
1355
1355
  }
1356
- else if (!this.hasWhitespace()) {
1357
- break;
1358
- }
1359
1356
  if (!node.addChild(this._parseBinaryExpr())) {
1360
1357
  break;
1361
1358
  }
@@ -384,7 +384,7 @@ var SelectorPrinting = /** @class */ (function () {
384
384
  var text = element.getText();
385
385
  if (_this.isPseudoElementIdentifier(text)) {
386
386
  specificity.tag++; // pseudo element
387
- break;
387
+ continue elementLoop;
388
388
  }
389
389
  // where and child selectors have zero specificity
390
390
  if (text.match(/^:where/i)) {
@@ -431,7 +431,7 @@ var SelectorPrinting = /** @class */ (function () {
431
431
  continue elementLoop;
432
432
  }
433
433
  specificity.attr++; //pseudo class
434
- break;
434
+ continue elementLoop;
435
435
  }
436
436
  if (element.getChildren().length > 0) {
437
437
  var itemSpecificity = calculateScore(element);
@@ -1,5 +1,5 @@
1
1
  // copied from js-beautify/js/lib/beautify-css.js
2
- // version: 1.14.2
2
+ // version: 1.14.3
3
3
  /* AUTO-GENERATED. DO NOT MODIFY. */
4
4
  /*
5
5
 
@@ -1092,6 +1092,9 @@ function Beautifier(source_text, options) {
1092
1092
  "@supports": true,
1093
1093
  "@document": true
1094
1094
  };
1095
+ this.NON_SEMICOLON_NEWLINE_PROPERTY = [
1096
+ "grid-template"
1097
+ ];
1095
1098
 
1096
1099
  }
1097
1100
 
@@ -1216,7 +1219,9 @@ Beautifier.prototype.beautify = function() {
1216
1219
  var enteringConditionalGroup = false;
1217
1220
  var insideAtExtend = false;
1218
1221
  var insideAtImport = false;
1222
+ var insideScssMap = false;
1219
1223
  var topCharacter = this._ch;
1224
+ var insideNonSemiColonValues = false;
1220
1225
  var whitespace;
1221
1226
  var isAfterSpace;
1222
1227
  var previous_ch;
@@ -1268,7 +1273,7 @@ Beautifier.prototype.beautify = function() {
1268
1273
 
1269
1274
  // Ensures any new lines following the comment are preserved
1270
1275
  this.eatWhitespace(true);
1271
- } else if (this._ch === '@') {
1276
+ } else if (this._ch === '@' || this._ch === '$') {
1272
1277
  this.preserveSingleSpace(isAfterSpace);
1273
1278
 
1274
1279
  // deal with less propery mixins @{...}
@@ -1339,7 +1344,12 @@ Beautifier.prototype.beautify = function() {
1339
1344
  this.indent();
1340
1345
  this._output.set_indent(this._indentLevel);
1341
1346
  } else {
1342
- this.indent();
1347
+ // inside mixin and first param is object
1348
+ if (previous_ch === '(') {
1349
+ this._output.space_before_token = false;
1350
+ } else if (previous_ch !== ',') {
1351
+ this.indent();
1352
+ }
1343
1353
  this.print_string(this._ch);
1344
1354
  }
1345
1355
 
@@ -1371,7 +1381,21 @@ Beautifier.prototype.beautify = function() {
1371
1381
  this._output.add_new_line(true);
1372
1382
  }
1373
1383
  }
1384
+ if (this._input.peek() === ')') {
1385
+ this._output.trim(true);
1386
+ if (this._options.brace_style === "expand") {
1387
+ this._output.add_new_line(true);
1388
+ }
1389
+ }
1374
1390
  } else if (this._ch === ":") {
1391
+
1392
+ for (var i = 0; i < this.NON_SEMICOLON_NEWLINE_PROPERTY.length; i++) {
1393
+ if (this._input.lookBack(this.NON_SEMICOLON_NEWLINE_PROPERTY[i])) {
1394
+ insideNonSemiColonValues = true;
1395
+ break;
1396
+ }
1397
+ }
1398
+
1375
1399
  if ((insideRule || enteringConditionalGroup) && !(this._input.lookBack("&") || this.foundNestedPseudoClass()) && !this._input.lookBack("(") && !insideAtExtend && parenLevel === 0) {
1376
1400
  // 'property: value' delimiter
1377
1401
  // which could be in a conditional group query
@@ -1404,6 +1428,7 @@ Beautifier.prototype.beautify = function() {
1404
1428
  this.print_string(this._ch + this.eatString(this._ch));
1405
1429
  this.eatWhitespace(true);
1406
1430
  } else if (this._ch === ';') {
1431
+ insideNonSemiColonValues = false;
1407
1432
  if (parenLevel === 0) {
1408
1433
  if (insidePropertyValue) {
1409
1434
  this.outdent();
@@ -1445,20 +1470,32 @@ Beautifier.prototype.beautify = function() {
1445
1470
  } else {
1446
1471
  this.preserveSingleSpace(isAfterSpace);
1447
1472
  this.print_string(this._ch);
1448
- this.eatWhitespace();
1449
- parenLevel++;
1450
- this.indent();
1473
+
1474
+ // handle scss/sass map
1475
+ if (insidePropertyValue && previous_ch === "$" && this._options.selector_separator_newline) {
1476
+ this._output.add_new_line();
1477
+ insideScssMap = true;
1478
+ } else {
1479
+ this.eatWhitespace();
1480
+ parenLevel++;
1481
+ this.indent();
1482
+ }
1451
1483
  }
1452
1484
  } else if (this._ch === ')') {
1453
1485
  if (parenLevel) {
1454
1486
  parenLevel--;
1455
1487
  this.outdent();
1456
1488
  }
1489
+ if (insideScssMap && this._input.peek() === ";" && this._options.selector_separator_newline) {
1490
+ insideScssMap = false;
1491
+ this.outdent();
1492
+ this._output.add_new_line();
1493
+ }
1457
1494
  this.print_string(this._ch);
1458
1495
  } else if (this._ch === ',') {
1459
1496
  this.print_string(this._ch);
1460
1497
  this.eatWhitespace(true);
1461
- if (this._options.selector_separator_newline && !insidePropertyValue && parenLevel === 0 && !insideAtImport && !insideAtExtend) {
1498
+ if (this._options.selector_separator_newline && (!insidePropertyValue || insideScssMap) && parenLevel === 0 && !insideAtImport && !insideAtExtend) {
1462
1499
  this._output.add_new_line();
1463
1500
  } else {
1464
1501
  this._output.space_before_token = true;
@@ -1492,8 +1529,13 @@ Beautifier.prototype.beautify = function() {
1492
1529
  this.print_string(' ');
1493
1530
  this.print_string(this._ch);
1494
1531
  } else {
1495
- this.preserveSingleSpace(isAfterSpace);
1532
+ var preserveAfterSpace = previous_ch === '"' || previous_ch === '\'';
1533
+ this.preserveSingleSpace(preserveAfterSpace || isAfterSpace);
1496
1534
  this.print_string(this._ch);
1535
+
1536
+ if (!this._output.just_added_newline() && this._input.peek() === '\n' && insideNonSemiColonValues) {
1537
+ this._output.add_new_line();
1538
+ }
1497
1539
  }
1498
1540
  }
1499
1541
 
@@ -1364,9 +1364,6 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
1364
1364
  }
1365
1365
  this.consumeToken();
1366
1366
  }
1367
- else if (!this.hasWhitespace()) {
1368
- break;
1369
- }
1370
1367
  if (!node.addChild(this._parseBinaryExpr())) {
1371
1368
  break;
1372
1369
  }
@@ -396,7 +396,7 @@ var __extends = (this && this.__extends) || (function () {
396
396
  var text = element.getText();
397
397
  if (_this.isPseudoElementIdentifier(text)) {
398
398
  specificity.tag++; // pseudo element
399
- break;
399
+ continue elementLoop;
400
400
  }
401
401
  // where and child selectors have zero specificity
402
402
  if (text.match(/^:where/i)) {
@@ -443,7 +443,7 @@ var __extends = (this && this.__extends) || (function () {
443
443
  continue elementLoop;
444
444
  }
445
445
  specificity.attr++; //pseudo class
446
- break;
446
+ continue elementLoop;
447
447
  }
448
448
  if (element.getChildren().length > 0) {
449
449
  var itemSpecificity = calculateScore(element);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vscode-css-languageservice",
3
- "version": "5.4.1",
3
+ "version": "5.4.2",
4
4
  "description": "Language service for CSS, LESS and SCSS",
5
5
  "main": "./lib/umd/cssLanguageService.js",
6
6
  "typings": "./lib/umd/cssLanguageService",
@@ -21,7 +21,7 @@
21
21
  "@typescript-eslint/parser": "^5.17.0",
22
22
  "@vscode/web-custom-data": "^0.3.9",
23
23
  "eslint": "^8.11.0",
24
- "js-beautify": "^1.14.2",
24
+ "js-beautify": "^1.14.3",
25
25
  "mocha": "^9.2.2",
26
26
  "rimraf": "^3.0.2",
27
27
  "typescript": "^4.5.5"