Reveal the selected item when cycling a picker's selection (#12950)
Release Notes: - Fixed a bug where the selected tab was not always shown when cycling between tabs with `ctrl-tab`.
This commit is contained in:
parent
0ac9af94e0
commit
76b0120665
5 changed files with 61 additions and 1 deletions
|
@ -37,6 +37,7 @@ editor = { workspace = true, features = ["test-support"] }
|
|||
env_logger.workspace = true
|
||||
gpui = { workspace = true, features = ["test-support"] }
|
||||
language = { workspace = true, features = ["test-support"] }
|
||||
picker = { workspace = true, features = ["test-support"] }
|
||||
serde_json.workspace = true
|
||||
theme = { workspace = true, features = ["test-support"] }
|
||||
workspace = { workspace = true, features = ["test-support"] }
|
||||
|
|
|
@ -1747,6 +1747,45 @@ async fn test_extending_modifiers_does_not_confirm_selection(cx: &mut gpui::Test
|
|||
active_file_picker(&workspace, cx);
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_repeat_toggle_action(cx: &mut gpui::TestAppContext) {
|
||||
let app_state = init_test(cx);
|
||||
app_state
|
||||
.fs
|
||||
.as_fake()
|
||||
.insert_tree(
|
||||
"/test",
|
||||
json!({
|
||||
"00.txt": "",
|
||||
"01.txt": "",
|
||||
"02.txt": "",
|
||||
"03.txt": "",
|
||||
"04.txt": "",
|
||||
"05.txt": "",
|
||||
}),
|
||||
)
|
||||
.await;
|
||||
|
||||
let project = Project::test(app_state.fs.clone(), ["/test".as_ref()], cx).await;
|
||||
let (workspace, cx) = cx.add_window_view(|cx| Workspace::test_new(project, cx));
|
||||
|
||||
cx.dispatch_action(Toggle::default());
|
||||
let picker = active_file_picker(&workspace, cx);
|
||||
picker.update(cx, |picker, _| {
|
||||
assert_eq!(picker.delegate.selected_index, 0);
|
||||
assert_eq!(picker.logical_scroll_top_index(), 0);
|
||||
});
|
||||
|
||||
// When toggling repeatedly, the picker scrolls to reveal the selected item.
|
||||
cx.dispatch_action(Toggle::default());
|
||||
cx.dispatch_action(Toggle::default());
|
||||
cx.dispatch_action(Toggle::default());
|
||||
picker.update(cx, |picker, _| {
|
||||
assert_eq!(picker.delegate.selected_index, 3);
|
||||
assert_eq!(picker.logical_scroll_top_index(), 3);
|
||||
});
|
||||
}
|
||||
|
||||
async fn open_close_queried_buffer(
|
||||
input: &str,
|
||||
expected_matches: usize,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue