fix(completion): stop offering status once its quote is closed
Some checks failed
Deploy to GitHub Pages / build (push) Failing after 23s
Deploy to GitHub Pages / deploy (push) Has been skipped

The pattern's trailing optional quote let a complete `status = "x"`
match, so the popup reopened after the closing quote. Drop it so the
match ends with the value, while still typing remains supported.
This commit is contained in:
Julien Calixte
2026-06-19 18:54:37 +02:00
parent e726675d77
commit be86b82823
2 changed files with 6 additions and 2 deletions

View File

@@ -66,6 +66,10 @@ describe("completion context", () => {
expect(labelsAt('[[feature]]\nstatus = "o|')).toEqual(["on-track", "off-track"])
})
it("offers nothing once the status value's quote is closed", () => {
expect(getCompletions(...atCaret('[[feature]]\nstatus = "on-track"|'))).toBeNull()
})
it("suggests feature names inside a milestone requires array", () => {
const source = '[[feature]]\nname = "Payments"\n\n[[milestone]]\nrequires = ["|'
expect(labelsAt(source)).toEqual(["Payments"])

View File

@@ -63,8 +63,8 @@ export function getCompletions(
const lineStart = source.lastIndexOf("\n", caret - 1) + 1
const linePrefix = source.slice(lineStart, caret)
// ── value: status = "<here>" ──────────────────────────────────────────────
const status = /^(\s*status\s*=\s*)"?([A-Za-z-]*)"?$/.exec(linePrefix)
// ── value: status = "<here>" — while typing, not once the quote is closed ──
const status = /^(\s*status\s*=\s*)"?([A-Za-z-]*)$/.exec(linePrefix)
if (status) {
const items = filter(
STATUSES.map((s) => ({ label: s, insert: `"${s}"` })),