@rohal12/spindle-lsp 0.15.19 → 0.15.20

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.19";
58
+ VERSION = false ? pkg.version : "0.15.20";
59
59
  }
60
60
  });
61
61
 
@@ -33212,6 +33212,8 @@ var init_variable_tracker = __esm({
33212
33212
  usagesByUri = /* @__PURE__ */ new Map();
33213
33213
  /** Per-URI list of transient variable usages. */
33214
33214
  transientUsagesByUri = /* @__PURE__ */ new Map();
33215
+ /** Executable assignments can replace a declaration's default shape anywhere in the story. */
33216
+ rootWritesByUri = /* @__PURE__ */ new Map();
33215
33217
  /**
33216
33218
  * Parse the StoryVariables passage content for declarations.
33217
33219
  * Each line like `$name = value` becomes a declaration.
@@ -33244,7 +33246,17 @@ var init_variable_tracker = __esm({
33244
33246
  this.removeDocument(uri);
33245
33247
  const usages = [];
33246
33248
  const transientUsages = [];
33249
+ const rootWrites = /* @__PURE__ */ new Set();
33247
33250
  for (const passage of markup.passages) {
33251
+ for (const piece of passage.pieces) {
33252
+ if (piece.kind !== "code") continue;
33253
+ try {
33254
+ for (const ref2 of parseCode(piece.code, piece.goal).refs) {
33255
+ if (ref2.write && (ref2.sigil === "$" || ref2.sigil === "%")) rootWrites.add(ref2.sigil + ref2.name);
33256
+ }
33257
+ } catch {
33258
+ }
33259
+ }
33248
33260
  for (const ref2 of collectVariableReferences2(passage)) {
33249
33261
  const usage = {
33250
33262
  uri,
@@ -33257,11 +33269,13 @@ var init_variable_tracker = __esm({
33257
33269
  }
33258
33270
  if (usages.length > 0) this.usagesByUri.set(uri, usages);
33259
33271
  if (transientUsages.length > 0) this.transientUsagesByUri.set(uri, transientUsages);
33272
+ if (rootWrites.size > 0) this.rootWritesByUri.set(uri, rootWrites);
33260
33273
  }
33261
33274
  /** Forget the usages recorded for a document, e.g. after it was deleted. */
33262
33275
  removeDocument(uri) {
33263
33276
  this.usagesByUri.delete(uri);
33264
33277
  this.transientUsagesByUri.delete(uri);
33278
+ this.rootWritesByUri.delete(uri);
33265
33279
  }
33266
33280
  /** Get all declared variables. */
33267
33281
  getDeclared() {
@@ -33315,11 +33329,12 @@ var init_variable_tracker = __esm({
33315
33329
  }
33316
33330
  /**
33317
33331
  * Get `$var.member` / `%var.member` accesses in a document where `var` is
33318
- * declared with an array literal default and `member` is not a property
33319
- * that JavaScript arrays have (so the access always yields undefined).
33332
+ * declared with an array literal default, with no known root assignment,
33333
+ * and `member` is not a property that JavaScript arrays have.
33320
33334
  */
33321
33335
  getArrayMemberAccesses(uri) {
33322
33336
  const results = [];
33337
+ const rootWrites = new Set([...this.rootWritesByUri.values()].flatMap((writes) => [...writes]));
33323
33338
  const sources = [
33324
33339
  ["$", this.usagesByUri.get(uri), this.variables.declared],
33325
33340
  ["%", this.transientUsagesByUri.get(uri), this.transients.declared]
@@ -33329,6 +33344,7 @@ var init_variable_tracker = __esm({
33329
33344
  const member = u.fullName.split(".")[1];
33330
33345
  if (member === void 0) continue;
33331
33346
  if (declared.get(u.baseName)?.type !== "array") continue;
33347
+ if (rootWrites.has(sigil + u.baseName)) continue;
33332
33348
  if (ARRAY_MEMBERS.has(member) || /^(0|[1-9]\d*)$/.test(member) && Number(member) < 4294967295) continue;
33333
33349
  results.push({ sigil, name: u.baseName, member, range: u.range });
33334
33350
  }
@@ -37969,7 +37985,7 @@ async function formatLf2(text3, options) {
37969
37985
  if (passage.body === "") continue;
37970
37986
  const role = parsePassageHeader(passage.header, passage.startLine);
37971
37987
  const kind = classifyPassage(passage.header);
37972
- const body = kind === "normal" && role && !isMarkupPassage(role) ? passage.body : await formatPassage(passage.body, {
37988
+ const body = role && (!isRuntimePassage({ name: role.name }) || kind === "normal" && !isMarkupPassage(role)) ? passage.body : await formatPassage(passage.body, {
37973
37989
  kind,
37974
37990
  prettier: prettier2?.prettier,
37975
37991
  prettierOptions: prettier2?.options,