fix: disable hash console completions

This commit is contained in:
Keisuke Hirata 2026-07-16 07:50:13 +09:00
parent ad66650369
commit 20654f9c40
No known key found for this signature in database
2 changed files with 4 additions and 5 deletions

View File

@ -22,7 +22,7 @@ function assertEquals<T>(actual: T, expected: T): void {
} }
} }
Deno.test("completionTokenAt detects TUI-style sigils before the cursor", () => { Deno.test("completionTokenAt detects command and file sigils before the cursor", () => {
assertEquals(completionTokenAt("open @src/ma", "open @src/ma".length), { assertEquals(completionTokenAt("open @src/ma", "open @src/ma".length), {
sigil: "@", sigil: "@",
kind: "file", kind: "file",
@ -32,6 +32,7 @@ Deno.test("completionTokenAt detects TUI-style sigils before the cursor", () =>
}); });
assertEquals(completionTokenAt(":comp", 5)?.kind, "command"); assertEquals(completionTokenAt(":comp", 5)?.kind, "command");
assertEquals(completionTokenAt("run /work", 9), null); assertEquals(completionTokenAt("run /work", 9), null);
assertEquals(completionTokenAt("ask #plain", "ask #plain".length), null);
}); });
Deno.test("applyCompletion replaces the active token and advances the cursor", () => { Deno.test("applyCompletion replaces the active token and advances the cursor", () => {

View File

@ -1,7 +1,7 @@
export type ComposerCompletionKind = "command" | "file"; export type ComposerCompletionKind = "command" | "file";
export type ComposerCompletionToken = { export type ComposerCompletionToken = {
sigil: ":" | "@" | "#"; sigil: ":" | "@";
kind: ComposerCompletionKind; kind: ComposerCompletionKind;
start: number; start: number;
end: number; end: number;
@ -35,7 +35,7 @@ export function completionTokenAt(
): ComposerCompletionToken | null { ): ComposerCompletionToken | null {
const boundedCursor = Math.max(0, Math.min(cursor, value.length)); const boundedCursor = Math.max(0, Math.min(cursor, value.length));
const before = value.slice(0, boundedCursor); const before = value.slice(0, boundedCursor);
const match = /(^|\s)([:@#])([^\s]*)$/.exec(before); const match = /(^|\s)([:@])([^\s]*)$/.exec(before);
if (!match) { if (!match) {
return null; return null;
} }
@ -83,8 +83,6 @@ function completionKindForSigil(
switch (sigil) { switch (sigil) {
case ":": case ":":
return "command"; return "command";
default:
return "file";
case "@": case "@":
return "file"; return "file";
} }