From 5d1584e4c40eca78924a6ffdc6df080c76d1bcf0 Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Sat, 8 Aug 2026 07:44:10 +0800 Subject: [PATCH] fix(palette): arm the first row when the palette opens MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `ListState::new` starts with no selected row, and it only picks one when a query *changes*. So opening the palette and pressing Return — the shortest path through the feature — did nothing at all, and until the user typed or pressed Down there was no row showing what Return was aimed at. The delegate did think row 0 was selected (`selected: Some(IndexPath:: default())`), which is why this never showed up as a missing-state bug: `selected_command()` answered correctly, but the highlight and the Confirm event both come from `ListState`, which disagreed. `build_list_with_delegate` now hands the list the delegate's own `first_row()` — the one that skips empty sections — right after construction, so all three palettes (root, plain, ssh-connect) open armed. Verified on screen: ⌘P now highlights "New Tab" immediately, and Return opens a tab instead of doing nothing. --- src/ui/palette.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/ui/palette.rs b/src/ui/palette.rs index bf9c8e22..5e59fae7 100644 --- a/src/ui/palette.rs +++ b/src/ui/palette.rs @@ -978,8 +978,17 @@ impl PaletteView { window: &mut Window, cx: &mut Context, ) -> Entity> { + let first = delegate.first_row(); let list = cx.new(|cx| ListState::new(delegate, window, cx).searchable(true)); - list.update(cx, |state, cx| state.focus(window, cx)); + list.update(cx, |state, cx| { + // `ListState::new` starts with nothing selected, and it only picks a + // row once a query changes. Opening the palette and pressing Return + // therefore did nothing at all, and until then no row showed what + // Return was aimed at. Every palette anywhere else arms the first + // row on open. + state.set_selected_index(first, window, cx); + state.focus(window, cx); + }); list }