Compare commits
3 Commits
d26ebeef71
...
be86b82823
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be86b82823 | ||
|
|
e726675d77 | ||
|
|
5a4fbb452d |
@@ -87,7 +87,9 @@ function accept(i: number) {
|
|||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
el.setSelectionRange(caret, caret)
|
el.setSelectionRange(caret, caret)
|
||||||
el.focus()
|
el.focus()
|
||||||
refresh() // chain, e.g. `status = ` immediately offers the enum values
|
// Chain only after completing a key (insert ends `= `), so its values pop
|
||||||
|
// up next. A value or header is terminal — re-running would re-offer it.
|
||||||
|
if (item.insert.endsWith("= ")) refresh()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -145,6 +147,12 @@ function escapeHtml(s: string): string {
|
|||||||
|
|
||||||
function onInput(e: Event) {
|
function onInput(e: Event) {
|
||||||
emit("update:modelValue", (e.target as HTMLTextAreaElement).value)
|
emit("update:modelValue", (e.target as HTMLTextAreaElement).value)
|
||||||
|
// Deleting text (backspace, forward-delete, cut) shouldn't summon the popup —
|
||||||
|
// the author is removing, not asking for suggestions. Close it and stop.
|
||||||
|
if ((e as InputEvent).inputType?.startsWith("delete")) {
|
||||||
|
completion.value = null
|
||||||
|
return
|
||||||
|
}
|
||||||
refresh()
|
refresh()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,6 +66,10 @@ describe("completion context", () => {
|
|||||||
expect(labelsAt('[[feature]]\nstatus = "o|')).toEqual(["on-track", "off-track"])
|
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", () => {
|
it("suggests feature names inside a milestone requires array", () => {
|
||||||
const source = '[[feature]]\nname = "Payments"\n\n[[milestone]]\nrequires = ["|'
|
const source = '[[feature]]\nname = "Payments"\n\n[[milestone]]\nrequires = ["|'
|
||||||
expect(labelsAt(source)).toEqual(["Payments"])
|
expect(labelsAt(source)).toEqual(["Payments"])
|
||||||
|
|||||||
@@ -63,8 +63,8 @@ export function getCompletions(
|
|||||||
const lineStart = source.lastIndexOf("\n", caret - 1) + 1
|
const lineStart = source.lastIndexOf("\n", caret - 1) + 1
|
||||||
const linePrefix = source.slice(lineStart, caret)
|
const linePrefix = source.slice(lineStart, caret)
|
||||||
|
|
||||||
// ── value: status = "<here>" ──────────────────────────────────────────────
|
// ── value: status = "<here>" — while typing, not once the quote is closed ──
|
||||||
const status = /^(\s*status\s*=\s*)"?([A-Za-z-]*)"?$/.exec(linePrefix)
|
const status = /^(\s*status\s*=\s*)"?([A-Za-z-]*)$/.exec(linePrefix)
|
||||||
if (status) {
|
if (status) {
|
||||||
const items = filter(
|
const items = filter(
|
||||||
STATUSES.map((s) => ({ label: s, insert: `"${s}"` })),
|
STATUSES.map((s) => ({ label: s, insert: `"${s}"` })),
|
||||||
|
|||||||
Reference in New Issue
Block a user