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 jk
Conrad Irwinb9c7bafc802e
diff --cc crates/gpui/src/key_dispatch.rsindex 146ba208678,77d280502cb..08ada73d10d--- a/crates/gpui/src/key_dispatch.rs+++ b/crates/gpui/src/key_dispatch.rs@@@ -1,6 -1,6 +1,6 @@@use crate::{- Action, ActionRegistry, DispatchPhase, EntityId, FocusId, KeyBinding, KeyContext, Keymap,- KeymatchResult, Keystroke, KeystrokeMatcher, WindowContext,+ Action, ActionRegistry, DispatchPhase, ElementContext, EntityId, FocusId, KeyBinding,- KeyContext, KeyMatch, Keymap, Keystroke, KeystrokeMatcher, WindowContext,++ KeyContext, Keymap, KeymatchResult, Keystroke, KeystrokeMatcher, WindowContext,};use collections::FxHashMap;use parking_lot::Mutex;diff --cc crates/gpui/src/window.rsindex 9b3d04929bb,5bf40510f78..2803d7c948c--- a/crates/gpui/src/window.rs+++ b/crates/gpui/src/window.rs@@@ -1,19 -1,15 +1,15 @@@use crate::{- px, size, transparent_black, Action, AnyDrag, AnyTooltip, AnyView, AppContext, Arena,- AsyncWindowContext, AvailableSpace, Bounds, BoxShadow, Context, Corners, CursorStyle,- DevicePixels, DispatchActionListener, DispatchNodeId, DispatchTree, DisplayId, Edges, Effect,- Entity, EntityId, EventEmitter, FileDropEvent, Flatten, FontId, GlobalElementId, GlyphId, Hsla,- ImageData, InputHandler, IsZero, KeyBinding, KeyContext, KeyDownEvent, KeyEvent,- KeymatchResult, KeystrokeEvent, LayoutId, Model, ModelContext, Modifiers, MonochromeSprite,- MouseButton, MouseEvent, MouseMoveEvent, MouseUpEvent, Path, Pixels, PlatformAtlas,- PlatformDisplay, PlatformInput, PlatformInputHandler, PlatformWindow, Point, PolychromeSprite,- PromptLevel, Quad, Render, RenderGlyphParams, RenderImageParams, RenderSvgParams, ScaledPixels,- Scene, Shadow, SharedString, Size, Style, SubscriberSet, Subscription, Surface,- TaffyLayoutEngine, Task, Underline, UnderlineStyle, View, VisualContext, WeakView,- WindowBounds, WindowOptions, SUBPIXEL_VARIANTS,+ px, size, transparent_black, Action, AnyDrag, AnyView, AppContext, Arena, AsyncWindowContext,+ AvailableSpace, Bounds, Context, Corners, CursorStyle, DispatchActionListener, DispatchNodeId,+ DispatchTree, DisplayId, Edges, Effect, Entity, EntityId, EventEmitter, FileDropEvent, Flatten,- GlobalElementId, Hsla, KeyBinding, KeyContext, KeyDownEvent, KeystrokeEvent, Model,- ModelContext, Modifiers, MouseButton, MouseMoveEvent, MouseUpEvent, Pixels, PlatformAtlas,- PlatformDisplay, PlatformInput, PlatformWindow, Point, PromptLevel, Render, ScaledPixels,- SharedString, Size, SubscriberSet, Subscription, TaffyLayoutEngine, Task, View, VisualContext,- WeakView, WindowBounds, WindowOptions,++ GlobalElementId, Hsla, KeyBinding, KeyContext, KeyDownEvent, KeymatchResult, KeystrokeEvent,++ Model, ModelContext, Modifiers, MouseButton, MouseMoveEvent, MouseUpEvent, Pixels,++ PlatformAtlas, PlatformDisplay, PlatformInput, PlatformWindow, Point, PromptLevel, Render,++ ScaledPixels, SharedString, Size, SubscriberSet, Subscription, TaffyLayoutEngine, Task, View,++ VisualContext, WeakView, WindowBounds, WindowOptions,};use anyhow::{anyhow, Context as _, Result};- use collections::{FxHashMap, FxHashSet};+ use collections::FxHashSet;use derive_more::{Deref, DerefMut};use futures::{channel::{mpsc, oneshot},@@@ -38,9 -33,11 +33,12 @@@ use std::atomic::{AtomicUsize, Ordering::SeqCst},Arc,},+ time::Duration,};- use util::{post_inc, ResultExt};+ use util::ResultExt;++ mod element_cx;+ pub use element_cx::*;const ACTIVE_DRAG_Z_INDEX: u8 = 1;@@@ -289,139 -285,11 +287,19 @@@ pub struct Windowpub(crate) focus_invalidated: bool,}+#[derive(Default, Debug)]+struct PendingInput {+ text: String,+ bindings: SmallVec<[KeyBinding; 1]>,+ focus: Option<FocusId>,+ timer: Option<Task<()>>,+}+pub(crate) struct ElementStateBox {- inner: Box<dyn Any>,- parent_view_id: EntityId,+ pub(crate) inner: Box<dyn Any>,+ pub(crate) parent_view_id: EntityId,#[cfg(debug_assertions)]- type_name: &'static str,- }-- struct RequestedInputHandler {- view_id: EntityId,- handler: Option<PlatformInputHandler>,- }-- struct TooltipRequest {- view_id: EntityId,- tooltip: AnyTooltip,- }-- pub(crate) struct Frame {- focus: Option<FocusId>,- window_active: bool,- pub(crate) element_states: FxHashMap<GlobalElementId, ElementStateBox>,- mouse_listeners: FxHashMap<TypeId, Vec<(StackingOrder, EntityId, AnyMouseListener)>>,- pub(crate) dispatch_tree: DispatchTree,- pub(crate) scene: Scene,- pub(crate) depth_map: Vec<(StackingOrder, EntityId, Bounds<Pixels>)>,- pub(crate) z_index_stack: StackingOrder,- pub(crate) next_stacking_order_id: u32,- next_root_z_index: u8,- content_mask_stack: Vec<ContentMask<Pixels>>,- element_offset_stack: Vec<Point<Pixels>>,- requested_input_handler: Option<RequestedInputHandler>,- tooltip_request: Option<TooltipRequest>,- cursor_styles: FxHashMap<EntityId, CursorStyle>,- requested_cursor_style: Option<CursorStyle>,- pub(crate) view_stack: Vec<EntityId>,- pub(crate) reused_views: FxHashSet<EntityId>,-- #[cfg(any(test, feature = "test-support"))]- pub(crate) debug_bounds: collections::FxHashMap<String, Bounds<Pixels>>,- }-- impl Frame {- fn new(dispatch_tree: DispatchTree) -> Self {- Frame {- focus: None,- window_active: false,- element_states: FxHashMap::default(),- mouse_listeners: FxHashMap::default(),- dispatch_tree,- scene: Scene::default(),- depth_map: Vec::new(),- z_index_stack: StackingOrder::default(),- next_stacking_order_id: 0,- next_root_z_index: 0,- content_mask_stack: Vec::new(),- element_offset_stack: Vec::new(),- requested_input_handler: None,- tooltip_request: None,- cursor_styles: FxHashMap::default(),- requested_cursor_style: None,- view_stack: Vec::new(),- reused_views: FxHashSet::default(),-- #[cfg(any(test, feature = "test-support"))]- debug_bounds: FxHashMap::default(),- }- }-- fn clear(&mut self) {- self.element_states.clear();- self.mouse_listeners.values_mut().for_each(Vec::clear);- self.dispatch_tree.clear();- self.depth_map.clear();- self.next_stacking_order_id = 0;- self.next_root_z_index = 0;- self.reused_views.clear();- self.scene.clear();- self.requested_input_handler.take();- self.tooltip_request.take();- self.cursor_styles.clear();- self.requested_cursor_style.take();- debug_assert_eq!(self.view_stack.len(), 0);- }-- fn focus_path(&self) -> SmallVec<[FocusId; 8]> {- self.focus- .map(|focus_id| self.dispatch_tree.focus_path(focus_id))- .unwrap_or_default()- }-- fn finish(&mut self, prev_frame: &mut Self) {- // Reuse mouse listeners that didn't change since the last frame.- for (type_id, listeners) in &mut prev_frame.mouse_listeners {- let next_listeners = self.mouse_listeners.entry(*type_id).or_default();- for (order, view_id, listener) in listeners.drain(..) {- if self.reused_views.contains(&view_id) {- next_listeners.push((order, view_id, listener));- }- }- }-- // Reuse entries in the depth map that didn't change since the last frame.- for (order, view_id, bounds) in prev_frame.depth_map.drain(..) {- if self.reused_views.contains(&view_id) {- match self- .depth_map- .binary_search_by(|(level, _, _)| order.cmp(level))- {- Ok(i) | Err(i) => self.depth_map.insert(i, (order, view_id, bounds)),- }- }- }-- // Retain element states for views that didn't change since the last frame.- for (element_id, state) in prev_frame.element_states.drain() {- if self.reused_views.contains(&state.parent_view_id) {- self.element_states.entry(element_id).or_insert(state);- }- }-- // Reuse geometry that didn't change since the last frame.- self.scene- .reuse_views(&self.reused_views, &mut prev_frame.scene);- self.scene.finish();- }+ pub(crate) type_name: &'static str,}impl Window {diff --cc crates/vim/src/test.rsindex da990c530c7,fa2dcb45cda..1819be7878b--- a/crates/vim/src/test.rs+++ b/crates/vim/src/test.rs@@@ -3,11 -3,8 +3,11 @@@ mod neovim_backed_test_contextmod neovim_connection;mod vim_test_context;+use std::time::Duration;+use command_palette::CommandPalette;use editor::DisplayPoint;- use gpui::{Action, KeyBinding};++use gpui::KeyBinding;pub use neovim_backed_binding_test_context::*;pub use neovim_backed_test_context::*;pub use vim_test_context::*;@@@ -15,7 -12,7 +15,7 @@@use indoc::indoc;use search::BufferSearchBar;- use crate::{insert::NormalBefore, motion, normal::InsertLineBelow, state::Mode, ModeIndicator};-use crate::{state::Mode, ModeIndicator};++use crate::{insert::NormalBefore, motion, state::Mode, ModeIndicator};#[gpui::test]async fn test_initially_disabled(cx: &mut gpui::TestAppContext) {