Merge remote-tracking branch 'origin/main' into go-to-definition
This commit is contained in:
@@ -854,6 +854,12 @@ impl MutableAppContext {
|
||||
self.cx.windows.keys().cloned()
|
||||
}
|
||||
|
||||
pub fn activate_window(&self, window_id: usize) {
|
||||
if let Some((_, window)) = self.presenters_and_platform_windows.get(&window_id) {
|
||||
window.activate()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn root_view<T: View>(&self, window_id: usize) -> Option<ViewHandle<T>> {
|
||||
self.cx
|
||||
.windows
|
||||
|
||||
@@ -86,6 +86,7 @@ pub trait Window: WindowContext {
|
||||
fn on_resize(&mut self, callback: Box<dyn FnMut()>);
|
||||
fn on_close(&mut self, callback: Box<dyn FnOnce()>);
|
||||
fn prompt(&self, level: PromptLevel, msg: &str, answers: &[&str]) -> oneshot::Receiver<usize>;
|
||||
fn activate(&self);
|
||||
}
|
||||
|
||||
pub trait WindowContext {
|
||||
|
||||
@@ -349,6 +349,12 @@ impl platform::Window for Window {
|
||||
done_rx
|
||||
}
|
||||
}
|
||||
|
||||
fn activate(&self) {
|
||||
unsafe {
|
||||
let _: () = msg_send![self.0.borrow().native_window, makeKeyAndOrderFront: nil];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl platform::WindowContext for Window {
|
||||
|
||||
@@ -229,6 +229,8 @@ impl super::Window for Window {
|
||||
self.last_prompt.replace(Some(done_tx));
|
||||
done_rx
|
||||
}
|
||||
|
||||
fn activate(&self) {}
|
||||
}
|
||||
|
||||
pub fn platform() -> Platform {
|
||||
|
||||
@@ -1432,10 +1432,11 @@ pub fn open_paths(
|
||||
// Open paths in existing workspace if possible
|
||||
let mut existing = None;
|
||||
for window_id in cx.window_ids().collect::<Vec<_>>() {
|
||||
if let Some(workspace) = cx.root_view::<Workspace>(window_id) {
|
||||
if workspace.update(cx, |view, cx| {
|
||||
if view.contains_paths(abs_paths, cx.as_ref()) {
|
||||
existing = Some(workspace.clone());
|
||||
if let Some(workspace_handle) = cx.root_view::<Workspace>(window_id) {
|
||||
if workspace_handle.update(cx, |workspace, cx| {
|
||||
if workspace.contains_paths(abs_paths, cx.as_ref()) {
|
||||
cx.activate_window(window_id);
|
||||
existing = Some(workspace_handle.clone());
|
||||
true
|
||||
} else {
|
||||
false
|
||||
|
||||
Reference in New Issue
Block a user