+11
-9
www/src/main.ts
+11
-9
www/src/main.ts
···
247
cursorPos = (before + candidate.name).length;
248
};
249
250
const updateCompletionCandidates = async () => {
251
// Don't try to get completion if worker isn't loaded
252
if (!isWorkerReady) return;
···
370
if (completionCandidates.length > 0) {
371
const cand = completionCandidates[completionIndex];
372
if (cand) {
373
-
currentLine = getLineWithCompletion(completionBaseLine, cand);
374
-
cursorPos = currentLine.length;
375
}
376
}
377
···
516
(completionIndex - 1 + completionCandidates.length) %
517
completionCandidates.length;
518
const candidate = completionCandidates[completionIndex];
519
-
currentLine = getLineWithCompletion(completionBaseLine, candidate);
520
-
cursorPos = currentLine.length;
521
await refreshPrompt();
522
break;
523
}
···
547
if (completionCandidates.length > 0 && e === "\x1b[B") {
548
completionIndex = (completionIndex + 1) % completionCandidates.length;
549
const candidate = completionCandidates[completionIndex];
550
-
currentLine = getLineWithCompletion(completionBaseLine, candidate);
551
-
cursorPos = currentLine.length;
552
await refreshPrompt();
553
break;
554
}
···
583
(completionIndex + 1) % completionCandidates.length;
584
585
const candidate = completionCandidates[completionIndex];
586
-
currentLine = getLineWithCompletion(completionBaseLine, candidate);
587
await refreshPrompt();
588
} else {
589
// Guard: ensure worker is ready
···
618
(completionIndex - 1 + completionCandidates.length) %
619
completionCandidates.length;
620
const candidate = completionCandidates[completionIndex];
621
-
currentLine = getLineWithCompletion(completionBaseLine, candidate);
622
-
cursorPos = currentLine.length;
623
await refreshPrompt();
624
}
625
break;
···
247
cursorPos = (before + candidate.name).length;
248
};
249
250
+
const applyCompletionFromBase = (baseLine: string, candidate: Candidate) => {
251
+
currentLine = getLineWithCompletion(baseLine, candidate);
252
+
const before = baseLine.slice(0, candidate.span_start);
253
+
cursorPos = (before + candidate.name).length;
254
+
};
255
+
256
const updateCompletionCandidates = async () => {
257
// Don't try to get completion if worker isn't loaded
258
if (!isWorkerReady) return;
···
376
if (completionCandidates.length > 0) {
377
const cand = completionCandidates[completionIndex];
378
if (cand) {
379
+
applyCompletionFromBase(completionBaseLine, cand);
380
}
381
}
382
···
521
(completionIndex - 1 + completionCandidates.length) %
522
completionCandidates.length;
523
const candidate = completionCandidates[completionIndex];
524
+
applyCompletionFromBase(completionBaseLine, candidate);
525
await refreshPrompt();
526
break;
527
}
···
551
if (completionCandidates.length > 0 && e === "\x1b[B") {
552
completionIndex = (completionIndex + 1) % completionCandidates.length;
553
const candidate = completionCandidates[completionIndex];
554
+
applyCompletionFromBase(completionBaseLine, candidate);
555
await refreshPrompt();
556
break;
557
}
···
586
(completionIndex + 1) % completionCandidates.length;
587
588
const candidate = completionCandidates[completionIndex];
589
+
applyCompletionFromBase(completionBaseLine, candidate);
590
await refreshPrompt();
591
} else {
592
// Guard: ensure worker is ready
···
621
(completionIndex - 1 + completionCandidates.length) %
622
completionCandidates.length;
623
const candidate = completionCandidates[completionIndex];
624
+
applyCompletionFromBase(completionBaseLine, candidate);
625
await refreshPrompt();
626
}
627
break;