Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Merge remote-tracking branch 'origin/main' into window-handles

Nathan Sobod687c3d81f0d
diff --cc Cargo.lock
index 6cd36252d1b,5afa1ebe625..467798ebf52
--- a/Cargo.lock
+++ b/Cargo.lock
@@@ -1649,12 -1649,15 +1649,21 @@@ dependencies =
"theme",
]
+[[package]]
+name = "convert_case"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
+
+ [[package]]
+ name = "convert_case"
+ version = "0.6.0"
+ source = "registry+https://github.com/rust-lang/crates.io-index"
+ checksum = "ec182b0ca2f35d8fc196cf3404988fd8b8c739a4d270ff118a398feb0cbec1ca"
+ dependencies = [
+ "unicode-segmentation",
+ ]
+
[[package]]
name = "copilot"
version = "0.1.0"
@@@ -2139,19 -2142,6 +2148,19 @@@ dependencies =
"serde",
]
+[[package]]
+name = "derive_more"
+version = "0.99.17"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321"
+dependencies = [
- "convert_case",
++ "convert_case 0.4.0",
+ "proc-macro2",
+ "quote",
+ "rustc_version 0.4.0",
+ "syn 1.0.109",
+]
+
[[package]]
name = "dhat"
version = "0.3.2"
@@@ -2333,6 -2323,7 +2342,7 @@@ dependencies =
"clock",
"collections",
"context_menu",
- "convert_case",
++ "convert_case 0.6.0",
"copilot",
"ctor",
"db",
diff --cc crates/gpui/src/app.rs
index bd3fbb8149f,d98033820bb..ff8e343c2ca
--- a/crates/gpui/src/app.rs
+++ b/crates/gpui/src/app.rs
@@@ -4064,52 -3943,6 +4064,54 @@@ impl AnyWindowHandle
{
self.update(cx, |cx| cx.add_view(build_view))
}
+
+ pub fn downcast<V: View>(self) -> Option<WindowHandle<V>> {
+ if self.root_view_type == TypeId::of::<V>() {
+ Some(WindowHandle {
+ any_handle: self,
+ root_view_type: PhantomData,
+ })
+ } else {
+ None
+ }
+ }
+
+ pub fn root_is<V: View>(&self) -> bool {
+ self.root_view_type == TypeId::of::<V>()
+ }
+
+ pub fn is_active<C: BorrowWindowContext>(&self, cx: &C) -> C::Result<bool> {
+ self.read_with(cx, |cx| cx.window.is_active)
+ }
+
+ pub fn remove<C: BorrowWindowContext>(&self, cx: &mut C) -> C::Result<()> {
+ self.update(cx, |cx| cx.remove_window())
+ }
+
++ #[cfg(any(test, feature = "test-support"))]
+ pub fn simulate_activation(&self, cx: &mut TestAppContext) {
+ self.update(cx, |cx| {
+ let other_window_ids = cx
+ .windows
+ .keys()
+ .filter(|window_id| **window_id != self.window_id)
+ .copied()
+ .collect::<Vec<_>>();
+
+ for window_id in other_window_ids {
+ cx.window_changed_active_status(window_id, false)
+ }
+
+ cx.window_changed_active_status(self.window_id, true)
+ });
+ }
+
++ #[cfg(any(test, feature = "test-support"))]
+ pub fn simulate_deactivation(&self, cx: &mut TestAppContext) {
+ self.update(cx, |cx| {
+ cx.window_changed_active_status(self.window_id, false);
+ })
+ }
}
#[repr(transparent)]