git_graph: Focus search editor on open (#63002)
Release Notes: - The git graph and git history view will now focus the search editor on initial focus
This commit is contained in:
1 parent
ff54ece5b8
commit
36ef5aeb8d
1 file changed
+57
-2
@@ -4108,8 +4108,8 @@ impl Render for GitGraph {
|
||||
impl EventEmitter<ItemEvent> for GitGraph {}
|
||||
|
||||
impl Focusable for GitGraph {
|
||||
fn focus_handle(&self, _cx: &App) -> FocusHandle {
|
||||
self.focus_handle.clone()
|
||||
fn focus_handle(&self, cx: &App) -> FocusHandle {
|
||||
self.search_state.editor.read(cx).focus_handle(cx)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6449,6 +6449,61 @@ mod tests {
|
||||
});
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_focus_handle_focuses_search_editor(cx: &mut TestAppContext) {
|
||||
init_test(cx);
|
||||
|
||||
let fs = FakeFs::new(cx.executor());
|
||||
fs.insert_tree(
|
||||
Path::new("/project"),
|
||||
serde_json::json!({
|
||||
".git": {},
|
||||
"file.txt": "content",
|
||||
}),
|
||||
)
|
||||
.await;
|
||||
|
||||
let project = Project::test(fs.clone(), [Path::new("/project")], cx).await;
|
||||
cx.run_until_parked();
|
||||
|
||||
let repository = project.read_with(cx, |project, cx| {
|
||||
project
|
||||
.active_repository(cx)
|
||||
.expect("should have a repository")
|
||||
});
|
||||
|
||||
let (multi_workspace, cx) = cx.add_window_view(|window, cx| {
|
||||
workspace::MultiWorkspace::test_new(project.clone(), window, cx)
|
||||
});
|
||||
let workspace_weak =
|
||||
multi_workspace.read_with(&*cx, |multi, _| multi.workspace().downgrade());
|
||||
|
||||
let git_graph = cx.new_window_entity(|window, cx| {
|
||||
GitGraph::new(
|
||||
repository.read(cx).id,
|
||||
project.read(cx).git_store().clone(),
|
||||
workspace_weak,
|
||||
None,
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
});
|
||||
cx.run_until_parked();
|
||||
|
||||
git_graph.update_in(cx, |graph, window, cx| {
|
||||
window.focus(&graph.focus_handle(cx), cx);
|
||||
assert!(
|
||||
graph
|
||||
.search_state
|
||||
.editor
|
||||
.read(cx)
|
||||
.focus_handle(cx)
|
||||
.is_focused(window),
|
||||
"focusing the git graph item should focus the search editor"
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
#[gpui::test]
|
||||
async fn test_row_height_matches_uniform_list_item_height(cx: &mut TestAppContext) {
|
||||
init_test(cx);
|
||||
|
||||
Reference in new issue
Block a user