prettier 3.7.0 → 3.7.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/doc.js CHANGED
@@ -1096,10 +1096,13 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
1096
1096
  mode: MODE_BREAK,
1097
1097
  doc
1098
1098
  }];
1099
- let out = [];
1099
+ let output = "";
1100
1100
  let shouldRemeasure = false;
1101
1101
  const lineSuffix2 = [];
1102
1102
  const cursorPositions = [];
1103
+ const settledOutput = [];
1104
+ const settledCursorPositions = [];
1105
+ let settledTextLength = 0;
1103
1106
  propagateBreaks(doc);
1104
1107
  while (commands.length > 0) {
1105
1108
  const {
@@ -1117,7 +1120,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
1117
1120
  newLine
1118
1121
  ) : doc2;
1119
1122
  if (formatted2) {
1120
- out.push(formatted2);
1123
+ output += formatted2;
1121
1124
  if (commands.length > 0) {
1122
1125
  position += get_string_width_default(formatted2);
1123
1126
  }
@@ -1133,15 +1136,12 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
1133
1136
  });
1134
1137
  }
1135
1138
  break;
1136
- case DOC_TYPE_CURSOR: {
1139
+ case DOC_TYPE_CURSOR:
1137
1140
  if (cursorPositions.length >= 2) {
1138
1141
  throw new Error("There are too many 'cursor' in doc.");
1139
1142
  }
1140
- const text = out.join("");
1141
- out = [text];
1142
- cursorPositions.push(text.length - 1);
1143
+ cursorPositions.push(settledTextLength + output.length);
1143
1144
  break;
1144
- }
1145
1145
  case DOC_TYPE_INDENT:
1146
1146
  commands.push({
1147
1147
  indent: makeIndent(indent2, options),
@@ -1380,7 +1380,7 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
1380
1380
  case MODE_FLAT:
1381
1381
  if (!doc2.hard) {
1382
1382
  if (!doc2.soft) {
1383
- out.push(" ");
1383
+ output += " ";
1384
1384
  position += 1;
1385
1385
  }
1386
1386
  break;
@@ -1399,17 +1399,17 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
1399
1399
  break;
1400
1400
  }
1401
1401
  if (doc2.literal) {
1402
- out.push(newLine);
1402
+ output += newLine;
1403
1403
  position = 0;
1404
1404
  if (indent2.root) {
1405
1405
  if (indent2.root.value) {
1406
- out.push(indent2.root.value);
1406
+ output += indent2.root.value;
1407
1407
  }
1408
1408
  position = indent2.root.length;
1409
1409
  }
1410
1410
  } else {
1411
1411
  trim2();
1412
- out.push(newLine + indent2.value);
1412
+ output += newLine + indent2.value;
1413
1413
  position = indent2.length;
1414
1414
  }
1415
1415
  break;
@@ -1432,32 +1432,38 @@ Expected it to be ${EXPECTED_TYPE_VALUES}.`;
1432
1432
  lineSuffix2.length = 0;
1433
1433
  }
1434
1434
  }
1435
- const formatted = out.join("");
1436
- if (cursorPositions.length !== 2) {
1435
+ const formatted = settledOutput.join("") + output;
1436
+ const finalCursorPositions = [...settledCursorPositions, ...cursorPositions];
1437
+ if (finalCursorPositions.length !== 2) {
1437
1438
  return {
1438
1439
  formatted
1439
1440
  };
1440
1441
  }
1441
- const cursorNodeStart = cursorPositions[0] + 1;
1442
+ const cursorNodeStart = finalCursorPositions[0];
1442
1443
  return {
1443
1444
  formatted,
1444
1445
  cursorNodeStart,
1445
1446
  cursorNodeText: formatted.slice(cursorNodeStart, method_at_default(
1446
1447
  /* OPTIONAL_OBJECT: false */
1447
1448
  0,
1448
- cursorPositions,
1449
+ finalCursorPositions,
1449
1450
  -1
1450
- ) + 1)
1451
+ ))
1451
1452
  };
1452
1453
  function trim2() {
1453
1454
  const {
1454
- text,
1455
+ text: trimmed,
1455
1456
  count
1456
- } = trimIndentation(out.join(""));
1457
- out = [text];
1457
+ } = trimIndentation(output);
1458
+ if (trimmed) {
1459
+ settledOutput.push(trimmed);
1460
+ settledTextLength += trimmed.length;
1461
+ }
1462
+ output = "";
1458
1463
  position -= count;
1459
- for (let index = 0; index < cursorPositions.length; index++) {
1460
- cursorPositions[index] = Math.min(cursorPositions[index], text.length - 1);
1464
+ if (cursorPositions.length > 0) {
1465
+ settledCursorPositions.push(...cursorPositions.map((position2) => Math.min(position2, settledTextLength)));
1466
+ cursorPositions.length = 0;
1461
1467
  }
1462
1468
  }
1463
1469
  }
package/doc.mjs CHANGED
@@ -1061,10 +1061,13 @@ function printDocToString(doc, options) {
1061
1061
  mode: MODE_BREAK,
1062
1062
  doc
1063
1063
  }];
1064
- let out = [];
1064
+ let output = "";
1065
1065
  let shouldRemeasure = false;
1066
1066
  const lineSuffix2 = [];
1067
1067
  const cursorPositions = [];
1068
+ const settledOutput = [];
1069
+ const settledCursorPositions = [];
1070
+ let settledTextLength = 0;
1068
1071
  propagateBreaks(doc);
1069
1072
  while (commands.length > 0) {
1070
1073
  const {
@@ -1082,7 +1085,7 @@ function printDocToString(doc, options) {
1082
1085
  newLine
1083
1086
  ) : doc2;
1084
1087
  if (formatted2) {
1085
- out.push(formatted2);
1088
+ output += formatted2;
1086
1089
  if (commands.length > 0) {
1087
1090
  position += get_string_width_default(formatted2);
1088
1091
  }
@@ -1098,15 +1101,12 @@ function printDocToString(doc, options) {
1098
1101
  });
1099
1102
  }
1100
1103
  break;
1101
- case DOC_TYPE_CURSOR: {
1104
+ case DOC_TYPE_CURSOR:
1102
1105
  if (cursorPositions.length >= 2) {
1103
1106
  throw new Error("There are too many 'cursor' in doc.");
1104
1107
  }
1105
- const text = out.join("");
1106
- out = [text];
1107
- cursorPositions.push(text.length - 1);
1108
+ cursorPositions.push(settledTextLength + output.length);
1108
1109
  break;
1109
- }
1110
1110
  case DOC_TYPE_INDENT:
1111
1111
  commands.push({
1112
1112
  indent: makeIndent(indent2, options),
@@ -1345,7 +1345,7 @@ function printDocToString(doc, options) {
1345
1345
  case MODE_FLAT:
1346
1346
  if (!doc2.hard) {
1347
1347
  if (!doc2.soft) {
1348
- out.push(" ");
1348
+ output += " ";
1349
1349
  position += 1;
1350
1350
  }
1351
1351
  break;
@@ -1364,17 +1364,17 @@ function printDocToString(doc, options) {
1364
1364
  break;
1365
1365
  }
1366
1366
  if (doc2.literal) {
1367
- out.push(newLine);
1367
+ output += newLine;
1368
1368
  position = 0;
1369
1369
  if (indent2.root) {
1370
1370
  if (indent2.root.value) {
1371
- out.push(indent2.root.value);
1371
+ output += indent2.root.value;
1372
1372
  }
1373
1373
  position = indent2.root.length;
1374
1374
  }
1375
1375
  } else {
1376
1376
  trim2();
1377
- out.push(newLine + indent2.value);
1377
+ output += newLine + indent2.value;
1378
1378
  position = indent2.length;
1379
1379
  }
1380
1380
  break;
@@ -1397,32 +1397,38 @@ function printDocToString(doc, options) {
1397
1397
  lineSuffix2.length = 0;
1398
1398
  }
1399
1399
  }
1400
- const formatted = out.join("");
1401
- if (cursorPositions.length !== 2) {
1400
+ const formatted = settledOutput.join("") + output;
1401
+ const finalCursorPositions = [...settledCursorPositions, ...cursorPositions];
1402
+ if (finalCursorPositions.length !== 2) {
1402
1403
  return {
1403
1404
  formatted
1404
1405
  };
1405
1406
  }
1406
- const cursorNodeStart = cursorPositions[0] + 1;
1407
+ const cursorNodeStart = finalCursorPositions[0];
1407
1408
  return {
1408
1409
  formatted,
1409
1410
  cursorNodeStart,
1410
1411
  cursorNodeText: formatted.slice(cursorNodeStart, method_at_default(
1411
1412
  /* OPTIONAL_OBJECT: false */
1412
1413
  0,
1413
- cursorPositions,
1414
+ finalCursorPositions,
1414
1415
  -1
1415
- ) + 1)
1416
+ ))
1416
1417
  };
1417
1418
  function trim2() {
1418
1419
  const {
1419
- text,
1420
+ text: trimmed,
1420
1421
  count
1421
- } = trimIndentation(out.join(""));
1422
- out = [text];
1422
+ } = trimIndentation(output);
1423
+ if (trimmed) {
1424
+ settledOutput.push(trimmed);
1425
+ settledTextLength += trimmed.length;
1426
+ }
1427
+ output = "";
1423
1428
  position -= count;
1424
- for (let index = 0; index < cursorPositions.length; index++) {
1425
- cursorPositions[index] = Math.min(cursorPositions[index], text.length - 1);
1429
+ if (cursorPositions.length > 0) {
1430
+ settledCursorPositions.push(...cursorPositions.map((position2) => Math.min(position2, settledTextLength)));
1431
+ cursorPositions.length = 0;
1426
1432
  }
1427
1433
  }
1428
1434
  }
package/index.cjs CHANGED
@@ -631,7 +631,7 @@ __export(version_evaluate_exports, {
631
631
  var version_evaluate_default;
632
632
  var init_version_evaluate = __esm({
633
633
  "src/main/version.evaluate.js"() {
634
- version_evaluate_default = "3.7.0";
634
+ version_evaluate_default = "3.7.2";
635
635
  }
636
636
  });
637
637
 
package/index.d.ts CHANGED
@@ -766,14 +766,14 @@ export interface BooleanSupportOption extends BaseSupportOption<"boolean"> {
766
766
  oppositeDescription?: string | undefined;
767
767
  }
768
768
 
769
- export interface BooleanArraySupportOption
770
- extends BaseSupportOption<"boolean"> {
769
+ export interface BooleanArraySupportOption extends BaseSupportOption<"boolean"> {
771
770
  default?: Array<{ value: boolean[] }> | undefined;
772
771
  array: true;
773
772
  }
774
773
 
775
- export interface ChoiceSupportOption<Value = any>
776
- extends BaseSupportOption<"choice"> {
774
+ export interface ChoiceSupportOption<
775
+ Value = any,
776
+ > extends BaseSupportOption<"choice"> {
777
777
  default?: Value | Array<{ value: Value }> | undefined;
778
778
  description: string;
779
779
  choices: Array<{
package/index.mjs CHANGED
@@ -18471,7 +18471,7 @@ var object_omit_default = omit;
18471
18471
  import * as doc from "./doc.mjs";
18472
18472
 
18473
18473
  // src/main/version.evaluate.js
18474
- var version_evaluate_default = "3.7.0";
18474
+ var version_evaluate_default = "3.7.2";
18475
18475
 
18476
18476
  // src/utils/public.js
18477
18477
  var public_exports = {};
@@ -2147,7 +2147,7 @@ var init_constants_evaluate = __esm({
2147
2147
  "angular",
2148
2148
  "lwc"
2149
2149
  ];
2150
- PRETTIER_VERSION = "3.7.0";
2150
+ PRETTIER_VERSION = "3.7.2";
2151
2151
  }
2152
2152
  });
2153
2153
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prettier",
3
- "version": "3.7.0",
3
+ "version": "3.7.2",
4
4
  "description": "Prettier is an opinionated code formatter",
5
5
  "bin": "./bin/prettier.cjs",
6
6
  "repository": "prettier/prettier",