mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-01 07:03:16 +03:00
Focus followed items when they become active if the pane is active
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
edc038a1cf
commit
4f27049305
@ -4311,6 +4311,7 @@ mod tests {
|
||||
.downcast::<Editor>()
|
||||
.unwrap()
|
||||
});
|
||||
assert!(cx_b.read(|cx| editor_b2.is_focused(cx)));
|
||||
assert_eq!(
|
||||
editor_b2.read_with(cx_b, |editor, cx| editor.project_path(cx)),
|
||||
Some((worktree_id, "2.txt").into())
|
||||
@ -4349,12 +4350,10 @@ mod tests {
|
||||
.condition(cx_b, |editor, cx| editor.text(cx) == "TWO")
|
||||
.await;
|
||||
|
||||
eprintln!("=========================>>>>>>>>");
|
||||
editor_a1.update(cx_a, |editor, cx| {
|
||||
editor.select_ranges([3..3], None, cx);
|
||||
editor.set_scroll_position(vec2f(0., 100.), cx);
|
||||
});
|
||||
eprintln!("=========================<<<<<<<<<");
|
||||
editor_b1
|
||||
.condition(cx_b, |editor, cx| editor.selected_ranges(cx) == vec![3..3])
|
||||
.await;
|
||||
|
@ -485,7 +485,7 @@ impl Pane {
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
fn focus_active_item(&mut self, cx: &mut ViewContext<Self>) {
|
||||
pub fn focus_active_item(&mut self, cx: &mut ViewContext<Self>) {
|
||||
if let Some(active_item) = self.active_item() {
|
||||
cx.focus(active_item);
|
||||
}
|
||||
|
@ -1902,6 +1902,9 @@ impl Workspace {
|
||||
|
||||
for (pane, item) in items_to_add {
|
||||
Pane::add_item(self, pane.clone(), item.boxed_clone(), false, cx);
|
||||
if pane == self.active_pane {
|
||||
pane.update(cx, |pane, cx| pane.focus_active_item(cx));
|
||||
}
|
||||
cx.notify();
|
||||
}
|
||||
None
|
||||
|
Loading…
Reference in New Issue
Block a user