fix: issues

This commit is contained in:
2026-03-01 11:38:14 +08:00
parent 05c93e0301
commit c977f366ea
2 changed files with 30 additions and 13 deletions
@@ -383,9 +383,8 @@ export function useCommander(
const setSelectedCompletion = (v: number | ((prev: number) => number)) => {
const comps = completions();
const maxVisible = 3;
const maxIdx = Math.min(comps.length - 1, maxVisible - 1);
const maxIdx = comps.length - 1;
if (typeof v === 'function') {
setSelectedCompletionState(prev => {
const next = v(prev);
@@ -399,8 +398,7 @@ export function useCommander(
const acceptCompletion = () => {
const idx = selectedCompletion();
const comps = completions();
// 确保索引在有效范围内
const validIdx = Math.min(idx, Math.min(comps.length - 1, 2));
const validIdx = Math.min(idx, comps.length - 1);
const comp = comps[validIdx];
if (!comp) return;