Merge branch 'main' into unborked-git-zed2-diagnostics-view

This commit is contained in:
Julia
2023-11-17 16:32:35 -05:00
33 changed files with 2523 additions and 2395 deletions
+1 -1
View File
@@ -72,7 +72,7 @@ impl ModalLayer {
cx.notify();
}
pub fn current_modal<V>(&self) -> Option<View<V>>
pub fn active_modal<V>(&self) -> Option<View<V>>
where
V: 'static,
{
+9 -4
View File
@@ -8,8 +8,8 @@ use anyhow::Result;
use collections::{HashMap, HashSet, VecDeque};
use gpui::{
actions, prelude::*, register_action, AppContext, AsyncWindowContext, Component, Div, EntityId,
EventEmitter, FocusHandle, Model, PromptLevel, Render, Task, View, ViewContext, VisualContext,
WeakView, WindowContext,
EventEmitter, FocusHandle, Focusable, Model, PromptLevel, Render, Task, View, ViewContext,
VisualContext, WeakView, WindowContext,
};
use parking_lot::Mutex;
use project2::{Project, ProjectEntryId, ProjectPath};
@@ -1017,7 +1017,11 @@ impl Pane {
.unwrap_or_else(|| item_index.min(self.items.len()).saturating_sub(1));
let should_activate = activate_pane || self.has_focus(cx);
self.activate_item(index_to_activate, should_activate, should_activate, cx);
if self.items.len() == 1 && should_activate {
self.focus_handle.focus(cx);
} else {
self.activate_item(index_to_activate, should_activate, should_activate, cx);
}
}
let item = self.items.remove(item_index);
@@ -1913,11 +1917,12 @@ impl Pane {
// }
impl Render for Pane {
type Element = Div<Self>;
type Element = Focusable<Self, Div<Self>>;
fn render(&mut self, cx: &mut ViewContext<Self>) -> Self::Element {
v_stack()
.key_context("Pane")
.track_focus(&self.focus_handle)
.size_full()
.on_action(|pane: &mut Self, action, cx| {
pane.close_active_item(action, cx)
+12 -9
View File
@@ -38,9 +38,9 @@ use futures::{
use gpui::{
actions, div, point, prelude::*, rems, size, Action, AnyModel, AnyView, AnyWeakView,
AppContext, AsyncAppContext, AsyncWindowContext, Bounds, Component, Div, Entity, EntityId,
EventEmitter, FocusHandle, GlobalPixels, KeyContext, Model, ModelContext, ParentComponent,
Point, Render, Size, Styled, Subscription, Task, View, ViewContext, WeakView, WindowBounds,
WindowContext, WindowHandle, WindowOptions,
EventEmitter, GlobalPixels, KeyContext, Model, ModelContext, ParentComponent, Point, Render,
Size, Styled, Subscription, Task, View, ViewContext, WeakView, WindowBounds, WindowContext,
WindowHandle, WindowOptions,
};
use item::{FollowableItem, FollowableItemHandle, Item, ItemHandle, ItemSettings, ProjectItem};
use itertools::Itertools;
@@ -433,7 +433,6 @@ pub enum Event {
pub struct Workspace {
weak_self: WeakView<Self>,
focus_handle: FocusHandle,
workspace_actions: Vec<Box<dyn Fn(Div<Workspace>) -> Div<Workspace>>>,
zoomed: Option<AnyWeakView>,
zoomed_position: Option<DockPosition>,
@@ -651,7 +650,6 @@ impl Workspace {
cx.defer(|this, cx| this.update_window_title(cx));
Workspace {
weak_self: weak_handle.clone(),
focus_handle: cx.focus_handle(),
zoomed: None,
zoomed_position: None,
center: PaneGroup::new(center_pane.clone()),
@@ -1450,6 +1448,11 @@ impl Workspace {
self.active_pane().read(cx).active_item()
}
pub fn active_item_as<I: 'static>(&self, cx: &AppContext) -> Option<View<I>> {
let item = self.active_item(cx)?;
item.to_any().downcast::<I>().ok()
}
fn active_project_path(&self, cx: &ViewContext<Self>) -> Option<ProjectPath> {
self.active_item(cx).and_then(|item| item.project_path(cx))
}
@@ -1570,7 +1573,7 @@ impl Workspace {
}
if focus_center {
cx.focus(&self.focus_handle);
self.active_pane.update(cx, |pane, cx| pane.focus(cx))
}
cx.notify();
@@ -1704,7 +1707,7 @@ impl Workspace {
}
if focus_center {
cx.focus(&self.focus_handle);
self.active_pane.update(cx, |pane, cx| pane.focus(cx))
}
if self.zoomed_position != dock_to_reveal {
@@ -3475,8 +3478,8 @@ impl Workspace {
div
}
pub fn current_modal<V: Modal + 'static>(&mut self, cx: &ViewContext<Self>) -> Option<View<V>> {
self.modal_layer.read(cx).current_modal()
pub fn active_modal<V: Modal + 'static>(&mut self, cx: &ViewContext<Self>) -> Option<View<V>> {
self.modal_layer.read(cx).active_modal()
}
pub fn toggle_modal<V: Modal, B>(&mut self, cx: &mut ViewContext<Self>, build: B)