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 branch 'main' into add-collab-tests

Mikayla9b30f490c761
diff --cc crates/gpui2/src/app.rs
index e016c193f2f,f2ac3a91cfa..0cec0fd0dae
--- a/crates/gpui2/src/app.rs
+++ b/crates/gpui2/src/app.rs
@@@ -16,10 -16,10 +16,10 @@@ pub use test_context::*
use crate::{
current_platform, image_cache::ImageCache, Action, AnyBox, AnyView, AnyWindowHandle,
AppMetadata, AssetSource, BackgroundExecutor, ClipboardItem, Context, DispatchPhase, DisplayId,
- Entity, FocusEvent, FocusHandle, FocusId, ForegroundExecutor, KeyBinding, Keymap, LayoutId,
- PathPromptOptions, Pixels, Platform, PlatformDisplay, Point, Render, SubscriberSet,
+ Entity, EventEmitter, FocusEvent, FocusHandle, FocusId, ForegroundExecutor, KeyBinding, Keymap,
- LayoutId, PathPromptOptions, Pixels, Platform, PlatformDisplay, Point, Render, SharedString,
- SubscriberSet, Subscription, SvgRenderer, Task, TextStyle, TextStyleRefinement, TextSystem,
- View, Window, WindowContext, WindowHandle, WindowId,
++ LayoutId, PathPromptOptions, Pixels, Platform, PlatformDisplay, Point, Render, SubscriberSet,
+ Subscription, SvgRenderer, Task, TextStyle, TextStyleRefinement, TextSystem, View, Window,
+ WindowContext, WindowHandle, WindowId,
};
use anyhow::{anyhow, Result};
use collections::{HashMap, HashSet, VecDeque};
@@@ -755,23 -669,6 +752,27 @@@ impl AppContext
self.globals_by_type.insert(global_type, Box::new(global));
}
++ #[track_caller]
+ pub fn clear_globals(&mut self) {
++ dbg!(core::panic::Location::caller());
+ //todo!(notify globals?)
+ self.globals_by_type.drain();
+ }
+
+ /// Set the value of the global of the given type.
++ #[track_caller]
+ pub fn remove_global<G: Any>(&mut self) -> G {
++ dbg!(core::panic::Location::caller());
+ let global_type = TypeId::of::<G>();
+ //todo!(notify globals?)
+ *self
+ .globals_by_type
+ .remove(&global_type)
+ .unwrap_or_else(|| panic!("no global added for {}", std::any::type_name::<G>()))
+ .downcast()
+ .unwrap()
+ }
+
/// Update the global of the given type with a closure. Unlike `global_mut`, this method provides
/// your closure with mutable access to the `AppContext` and the global simultaneously.
pub fn update_global<G: 'static, R>(&mut self, f: impl FnOnce(&mut G, &mut Self) -> R) -> R {
diff --cc crates/gpui2/src/app/test_context.rs
index 1ee48b43543,530138e21e0..eb5ce283a57
--- a/crates/gpui2/src/app/test_context.rs
+++ b/crates/gpui2/src/app/test_context.rs
@@@ -1,7 -1,7 +1,8 @@@
use crate::{
AnyView, AnyWindowHandle, AppCell, AppContext, AsyncAppContext, BackgroundExecutor, Context,
- EventEmitter, ForegroundExecutor, Model, ModelContext, Render, Result, Task, TestDispatcher,
- TestPlatform, ViewContext, VisualContext, WindowContext, WindowHandle, WindowOptions,
+ EventEmitter, ForegroundExecutor, InputEvent, KeyDownEvent, Keystroke, Model, ModelContext,
- Result, Task, TestDispatcher, TestPlatform, WindowContext,
++ Render, Result, Task, TestDispatcher, TestPlatform, ViewContext, VisualContext, WindowContext,
++ WindowHandle, WindowOptions,
};
use anyhow::{anyhow, bail};
use futures::{Stream, StreamExt};