@rohal12/spindle-lsp 0.15.44 → 0.15.46
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 +36 -14
- package/dist/bin.js.map +3 -3
- package/package.json +1 -1
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.
|
|
58
|
+
VERSION = false ? pkg.version : "0.15.46";
|
|
59
59
|
}
|
|
60
60
|
});
|
|
61
61
|
|
|
@@ -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
|
|
32883
|
-
const
|
|
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
|
|
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);
|
|
@@ -33086,7 +33091,7 @@ var init_passage_index = __esm({
|
|
|
33086
33091
|
getAllPassages() {
|
|
33087
33092
|
const result2 = [];
|
|
33088
33093
|
for (const uri of this.uris()) {
|
|
33089
|
-
|
|
33094
|
+
for (const passage of this.byUri.get(uri)) result2.push(passage);
|
|
33090
33095
|
}
|
|
33091
33096
|
return result2;
|
|
33092
33097
|
}
|
|
@@ -36179,16 +36184,21 @@ function declarationsOf(workspace, name) {
|
|
|
36179
36184
|
return new Map(markup.declarations.declarations.map((declaration) => [declaration.name, declaration.schema]));
|
|
36180
36185
|
}
|
|
36181
36186
|
function markupDiagnostics(passage, story, workspace) {
|
|
36182
|
-
|
|
36187
|
+
const found = story.markup.get(passage) ?? [];
|
|
36188
|
+
const tokens2 = /* @__PURE__ */ new Map();
|
|
36189
|
+
if (found.some((diagnostic) => diagnostic.code === "unknown-macro")) {
|
|
36190
|
+
for (const token of macroTokens(passage)) tokens2.set(token.start, token);
|
|
36191
|
+
}
|
|
36192
|
+
return found.map((diagnostic) => fromMarkup(passage, diagnostic, workspace, tokens2));
|
|
36183
36193
|
}
|
|
36184
|
-
function fromMarkup(passage, found, workspace) {
|
|
36194
|
+
function fromMarkup(passage, found, workspace, tokens2) {
|
|
36185
36195
|
const range2 = passage.range(...visibleSpan(passage.content, found.start, found.end));
|
|
36186
36196
|
const name = text2(found.data?.name);
|
|
36187
36197
|
let code = MARKUP_CODES[found.code];
|
|
36188
36198
|
let data2;
|
|
36189
36199
|
switch (found.code) {
|
|
36190
36200
|
case "unknown-macro": {
|
|
36191
|
-
const token =
|
|
36201
|
+
const token = tokens2.get(found.start);
|
|
36192
36202
|
data2 = {
|
|
36193
36203
|
kind: "unknown-macro",
|
|
36194
36204
|
name,
|
|
@@ -90041,12 +90051,23 @@ function addMacroToYamlConfig(text3, macroName) {
|
|
|
90041
90051
|
if (doc.errors.length > 0) return null;
|
|
90042
90052
|
if (doc.contents !== null && !(0, import_yaml3.isMap)(doc.contents)) return null;
|
|
90043
90053
|
const path2 = macrosPath(doc.toJS());
|
|
90044
|
-
|
|
90045
|
-
|
|
90046
|
-
|
|
90047
|
-
|
|
90048
|
-
|
|
90054
|
+
for (let depth = 1; depth <= path2.length; depth++) {
|
|
90055
|
+
const prefix = path2.slice(0, depth);
|
|
90056
|
+
const node2 = doc.getIn(prefix, true);
|
|
90057
|
+
if ((0, import_yaml3.isAlias)(node2)) {
|
|
90058
|
+
let value = node2.toJS(doc);
|
|
90059
|
+
if (depth < path2.length && (0, import_yaml3.isMap)(node2.resolve(doc))) {
|
|
90060
|
+
const key = path2[depth];
|
|
90061
|
+
const child = value[key];
|
|
90062
|
+
if (child !== null && typeof child === "object" && !Array.isArray(child)) {
|
|
90063
|
+
value = { ...value, [key]: { ...child } };
|
|
90064
|
+
}
|
|
90065
|
+
}
|
|
90066
|
+
doc.setIn(prefix, doc.createNode(value));
|
|
90067
|
+
}
|
|
90049
90068
|
}
|
|
90069
|
+
const parent = path2.length > 1 ? doc.getIn(path2.slice(0, -1), true) : doc.contents;
|
|
90070
|
+
const macros = doc.getIn(path2, true);
|
|
90050
90071
|
if ((0, import_yaml3.isMap)(macros) && definesMacro(macros.toJS(doc), macroName)) return null;
|
|
90051
90072
|
if ((0, import_yaml3.isMap)(parent) && (0, import_yaml3.isMap)(macros) && !macros.flow && macros.items.length > 0 && macros.range) {
|
|
90052
90073
|
const macrosKey = parent.items.find((p) => (0, import_yaml3.isScalar)(p.key) && p.key.value === "macros")?.key;
|
|
@@ -90556,9 +90577,10 @@ function computeDocumentLinks(uri, workspace) {
|
|
|
90556
90577
|
const doc = workspace.markup.get(uri);
|
|
90557
90578
|
if (!doc) return [];
|
|
90558
90579
|
const links = [];
|
|
90580
|
+
const targets = new Map(workspace.passages.getEffectivePassages().map((passage) => [passage.name, passage]));
|
|
90559
90581
|
for (const ref2 of documentPassageRefs(doc)) {
|
|
90560
90582
|
if (ref2.form !== "bracket") continue;
|
|
90561
|
-
const targetPassage =
|
|
90583
|
+
const targetPassage = targets.get(ref2.name);
|
|
90562
90584
|
links.push({
|
|
90563
90585
|
range: ref2.range,
|
|
90564
90586
|
target: targetPassage ? `${targetPassage.uri}#L${targetPassage.range.start.line + 1}` : void 0
|