fix(console): apply review fixes for first-keystroke race and exact-match Tab
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
40961eacdd
commit
cdb6a87960
1 changed files with 6 additions and 0 deletions
|
|
@ -93,6 +93,9 @@ function bindConsoleAutocomplete(form) {
|
|||
const chosen = items[highlightIdx];
|
||||
const slice = firstTokenSlice(input.value, input.selectionStart || 0);
|
||||
if (!slice) return;
|
||||
// If the first token is already exactly the chosen name, accepting it
|
||||
// would be a no-op; close the dropdown so Tab feels responsive.
|
||||
if (slice.token === chosen.name) { close(); return; }
|
||||
const before = input.value.slice(0, slice.from);
|
||||
const after = input.value.slice(slice.to);
|
||||
input.value = before + chosen.name + after;
|
||||
|
|
@ -116,6 +119,9 @@ function bindConsoleAutocomplete(form) {
|
|||
input.addEventListener("focus", async () => {
|
||||
if (!vocab) {
|
||||
vocab = await loadVocab();
|
||||
// If the user already typed during the fetch, rank now so the
|
||||
// dropdown doesn't appear to lag a keystroke behind on cold load.
|
||||
if (vocab && document.activeElement === input) recompute();
|
||||
}
|
||||
}, { once: true });
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue