@heroiclands/content-language-server 0.2.0 → 0.2.1

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.
@@ -37,13 +37,13 @@ An explicitly configured foreign project can be searched even when it is not a d
37
37
 
38
38
  ### Address completion
39
39
 
40
- Completion inside an unfinished `[[...` link searches the selected projects' saved indexes. The query matches anywhere in a note's full name, aliases, shortcode, short Address, or canonical Address. The existing `nameAscii` and `aliasesAscii` fields supply typeable forms of names with non-ASCII characters. The server builds lowercase search keys in memory when it loads an index and transliterates the query with the same rule. The JSONL format carries no separate search field.
40
+ Completion inside a `[[...` link searches the selected projects' saved indexes, including when an editor inserts the closing `]]` after the cursor. The query matches anywhere in a note's full name, aliases, shortcode, short Address, or canonical Address. The existing `nameAscii` and `aliasesAscii` fields supply typeable forms of names with non-ASCII characters. The server builds lowercase search keys in memory when it loads an index and transliterates the query with the same rule. The JSONL format carries no separate search field.
41
41
 
42
42
  Each result identifies its owning package and canonical Address. Readable `note` content, systemless `none` targets, and game system documents stay selectable even when they share a Markdown file. An ordinary `[[link|text]]` defaults to `note`, while an embedded `![[link|text]]` defaults to `none` and uses `image` as the type of a bare shortcode. Stating a system selects that exact target: `[[macro-autoattack|Text]]` reaches the readable note, and `[[none-macro-autoattack|Text]]` reaches the Macro. An embed offers asset targets and can reach an icon with `![[icon-anvil|Anvil]]`.
43
43
 
44
44
  The text edit inserts the shortest Address that parses to the selected target at the cursor. A local game system document can require `sohl-being-bctrncml`, while a target in another package requires a fully qualified Address. A `[[...#` query completes anchors from the selected note. Completion in a declared frontmatter Address field uses that field's type and system defaults: image, icon, and folder fields use `none`; other fields use their game system block or `note` outside one. Explicit system segments keep their stated meaning. Input `doc<type>` aliases select readable note records; generated records and completion candidates use the authored type.
45
45
 
46
- The server reads open buffer text to locate the cursor and replacement range. Candidate metadata comes from the saved JSONL index; unsaved frontmatter changes do not add candidates. Completion leaves existing display text and closed wikilinks alone. A missing foreign index is reported through the usual LSP status message while other indexed projects remain available.
46
+ The server reads open buffer text to locate the cursor and replacement range. Candidate metadata comes from the saved JSONL index; unsaved frontmatter changes do not add candidates. Completion preserves closing brackets immediately after the cursor and ignores positions within existing display text. A missing foreign index is reported through the usual LSP status message while other indexed projects remain available.
47
47
 
48
48
  ## Foreign content projects
49
49
 
@@ -130,10 +130,11 @@ function mayCompleteAddress(text, offset) {
130
130
  const lineEnd = text.indexOf("\n", offset);
131
131
  const before = text.slice(lineStart, offset);
132
132
  const open = before.lastIndexOf("[[");
133
+ const after = text.slice(offset, lineEnd < 0 ? text.length : lineEnd);
133
134
  return (
134
135
  open >= 0 &&
135
136
  !before.slice(open + 2).includes("]]") &&
136
- !text.slice(offset, lineEnd < 0 ? text.length : lineEnd).includes("]]")
137
+ (!after.includes("]]") || after.startsWith("]]"))
137
138
  );
138
139
  }
139
140
 
@@ -495,7 +496,8 @@ export class ContentWorkspace {
495
496
  const open = before.lastIndexOf("[[");
496
497
  if (open < 0 || before.slice(open + 2).includes("]]")) return null;
497
498
  const embed = open > 0 && before[open - 1] === "!";
498
- if (text.slice(offset, lineEnd < 0 ? text.length : lineEnd).includes("]]")) return null;
499
+ const after = text.slice(offset, lineEnd < 0 ? text.length : lineEnd);
500
+ if (after.includes("]]") && !after.startsWith("]]")) return null;
499
501
  const from = lineStart + open + 2;
500
502
  const written = text.slice(from, offset);
501
503
  if (written.includes("|") || written.includes("[") || written.includes("]")) return null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heroiclands/content-language-server",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "Language server for HeroicLands content projects",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "type": "module",