0.1.13 improve completion

This commit is contained in:
2026-08-04 17:53:11 +02:00
parent 6794896ac7
commit f8187da611
12 changed files with 844 additions and 36 deletions
+40
View File
@@ -34,6 +34,46 @@ test("closed quote still resolves value context", () => {
assert.equal(ctx.valuePrefix, "GROUND");
});
test("multi-line unterminated quote keeps attribute-value context", () => {
const text =
`<AssetDeclaration>\n` +
` <ObjectCreationList id="OCL_CrateSpawn">\n` +
` <CreateObject\n` +
` Options="IGNORE_ALL_OBJECTS"\n` +
` Disposition="`;
const cursor = text.length;
const doc = parseXml(text);
const ctx = analyzeContext(doc, text, cursor);
assert.equal(ctx.kind, "attribute-value");
assert.equal(ctx.attr?.name, "Disposition");
assert.equal(ctx.valuePrefix, "");
assert.equal(ctx.element?.name, "CreateObject");
});
test("multi-line unterminated value prefix includes typed flags", () => {
const text =
`<AssetDeclaration>\n` +
` <ObjectCreationList id="OCL_CrateSpawn">\n` +
` <CreateObject\n` +
` Options="IGNORE_ALL_OBJECTS"\n` +
` Disposition="RANDOM_FORCE `;
const cursor = text.length;
const doc = parseXml(text);
const ctx = analyzeContext(doc, text, cursor);
assert.equal(ctx.kind, "attribute-value");
assert.equal(ctx.attr?.name, "Disposition");
assert.equal(ctx.valuePrefix, "RANDOM_FORCE ");
});
test("cursor after a closed quote is an attribute-name context", () => {
const text = `<Locomotor id="x" Surfaces="GROUND">\n</Locomotor>`;
const cursor = text.indexOf('GROUND"') + 'GROUND"'.length;
const doc = parseXml(text);
const ctx = analyzeContext(doc, text, cursor);
assert.equal(ctx.kind, "attribute-name");
assert.equal(ctx.attr, null);
});
test("splitListValuePrefix isolates the token being edited", () => {
assert.deepEqual(splitListValuePrefix("GROUND WA"), { token: "WA", start: 7 });
assert.deepEqual(splitListValuePrefix("GROUND "), { token: "", start: 7 });