@rohal12/spindle-lsp 0.15.43 → 0.15.45

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/dist/bin.js CHANGED
@@ -55,7 +55,7 @@ var VERSION;
55
55
  var init_version = __esm({
56
56
  "src/version.ts"() {
57
57
  "use strict";
58
- VERSION = false ? pkg.version : "0.15.43";
58
+ VERSION = false ? pkg.version : "0.15.45";
59
59
  }
60
60
  });
61
61
 
@@ -3546,7 +3546,7 @@ var require_identity = __commonJS({
3546
3546
  var SCALAR = /* @__PURE__ */ Symbol.for("yaml.scalar");
3547
3547
  var SEQ = /* @__PURE__ */ Symbol.for("yaml.seq");
3548
3548
  var NODE_TYPE = /* @__PURE__ */ Symbol.for("yaml.node.type");
3549
- var isAlias = (node2) => !!node2 && typeof node2 === "object" && node2[NODE_TYPE] === ALIAS;
3549
+ var isAlias2 = (node2) => !!node2 && typeof node2 === "object" && node2[NODE_TYPE] === ALIAS;
3550
3550
  var isDocument = (node2) => !!node2 && typeof node2 === "object" && node2[NODE_TYPE] === DOC;
3551
3551
  var isMap2 = (node2) => !!node2 && typeof node2 === "object" && node2[NODE_TYPE] === MAP;
3552
3552
  var isPair = (node2) => !!node2 && typeof node2 === "object" && node2[NODE_TYPE] === PAIR;
@@ -3581,7 +3581,7 @@ var require_identity = __commonJS({
3581
3581
  exports.SCALAR = SCALAR;
3582
3582
  exports.SEQ = SEQ;
3583
3583
  exports.hasAnchor = hasAnchor;
3584
- exports.isAlias = isAlias;
3584
+ exports.isAlias = isAlias2;
3585
3585
  exports.isCollection = isCollection;
3586
3586
  exports.isDocument = isDocument;
3587
3587
  exports.isMap = isMap2;
@@ -32868,6 +32868,10 @@ function encodePassageName(name) {
32868
32868
  const parsed = parseTwee(`:: ${encoded}`);
32869
32869
  return parsed.passages.length === 1 && parsed.passages[0].name === name && !parsed.diagnostics.some((d) => d.level === "error") ? encoded : void 0;
32870
32870
  }
32871
+ function trimmedEnd(text3, end = text3.length) {
32872
+ while (end > 0 && new RegExp("\\p{White_Space}", "u").test(text3[end - 1])) end--;
32873
+ return end;
32874
+ }
32871
32875
  function parsePassageHeader(rawLine, lineNumber) {
32872
32876
  const line = withoutCr(rawLine);
32873
32877
  const bomLength = /^\uFEFF*/.exec(line)[0].length;
@@ -32879,8 +32883,9 @@ function parsePassageHeader(rawLine, lineNumber) {
32879
32883
  delimiter.lastIndex = nameStart;
32880
32884
  const first = delimiter.exec(escaped);
32881
32885
  const boundary = first?.index ?? line.length;
32882
- const nameEnd = escaped.slice(0, boundary).replace(new RegExp("\\p{White_Space}+$", "u"), "").length;
32883
- const name = line.slice(nameStart, nameEnd).replace(/\\(.|$)/g, "$1").replace(new RegExp("^\\p{White_Space}+|\\p{White_Space}+$", "gu"), "");
32886
+ const nameEnd = trimmedEnd(escaped, boundary);
32887
+ const decodedName = line.slice(nameStart, nameEnd).replace(/\\(.|$)/g, "$1").replace(new RegExp("^\\p{White_Space}+", "u"), "");
32888
+ const name = decodedName.slice(0, trimmedEnd(decodedName));
32884
32889
  if (!name) return null;
32885
32890
  let rest = boundary;
32886
32891
  let tags = [];
@@ -32894,7 +32899,7 @@ function parsePassageHeader(rawLine, lineNumber) {
32894
32899
  }
32895
32900
  let meta3;
32896
32901
  if (rest < line.length) {
32897
- const raw = line.slice(rest).replace(new RegExp("\\p{White_Space}+$", "u"), "");
32902
+ const raw = line.slice(rest, trimmedEnd(line));
32898
32903
  if (escaped[rest] !== "{" || !raw.endsWith("}")) return null;
32899
32904
  try {
32900
32905
  meta3 = JSON.parse(raw);
@@ -36348,12 +36353,13 @@ function childDiagnostics(passage, node2, token, workspace) {
36348
36353
  if (!constraints || constraints.length === 0 || !node2.body?.close) return [];
36349
36354
  const direct = [...node2.body.children];
36350
36355
  for (const branch of node2.body.branches) direct.push({ token: branch.tag, start: branch.tag.start, end: branch.tag.end }, ...branch.children);
36356
+ const branchTags = new Set(node2.body.branches.map((branch) => branch.tag));
36351
36357
  const consumesOptions = macro?.source === "builtin" && ["listbox", "cycle"].includes(token.name.toLowerCase());
36352
36358
  const counts = /* @__PURE__ */ Object.create(null);
36353
36359
  for (const child of direct) {
36354
36360
  if (child.token.type !== "macro" || child.token.isClose) continue;
36355
36361
  const key = child.token.name.toLowerCase();
36356
- if (consumesOptions && key === "option" || workspace.getEffectiveMacro(key)) counts[key] = (counts[key] ?? 0) + 1;
36362
+ if (branchTags.has(child.token) || consumesOptions && key === "option" || workspace.getEffectiveMacro(key)) counts[key] = (counts[key] ?? 0) + 1;
36357
36363
  }
36358
36364
  const diagnostics = [];
36359
36365
  const range2 = passage.range(token.start, token.end);
@@ -90040,6 +90046,21 @@ function addMacroToYamlConfig(text3, macroName) {
90040
90046
  if (doc.errors.length > 0) return null;
90041
90047
  if (doc.contents !== null && !(0, import_yaml3.isMap)(doc.contents)) return null;
90042
90048
  const path2 = macrosPath(doc.toJS());
90049
+ for (let depth = 1; depth <= path2.length; depth++) {
90050
+ const prefix = path2.slice(0, depth);
90051
+ const node2 = doc.getIn(prefix, true);
90052
+ if ((0, import_yaml3.isAlias)(node2)) {
90053
+ let value = node2.toJS(doc);
90054
+ if (depth < path2.length && (0, import_yaml3.isMap)(node2.resolve(doc))) {
90055
+ const key = path2[depth];
90056
+ const child = value[key];
90057
+ if (child !== null && typeof child === "object" && !Array.isArray(child)) {
90058
+ value = { ...value, [key]: { ...child } };
90059
+ }
90060
+ }
90061
+ doc.setIn(prefix, doc.createNode(value));
90062
+ }
90063
+ }
90043
90064
  const parent = path2.length > 1 ? doc.getIn(path2.slice(0, -1), true) : doc.contents;
90044
90065
  const macros = doc.getIn(path2, true);
90045
90066
  if ((0, import_yaml3.isMap)(macros) && definesMacro(macros.toJS(doc), macroName)) return null;