fix(completion): stop offering status once its quote is closed
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:
@@ -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"])
|
||||
|
||||
@@ -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}"` })),
|
||||
|
||||
Reference in New Issue
Block a user