mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-26 10:40:54 +00:00
Merge branch 'main' into randomized-tests-operation-script
This commit is contained in:
commit
016343e65d
148 changed files with 1283 additions and 1287 deletions
|
@ -477,6 +477,7 @@
|
|||
"cmd-c": "project_panel::Copy",
|
||||
"cmd-v": "project_panel::Paste",
|
||||
"cmd-alt-c": "project_panel::CopyPath",
|
||||
"alt-cmd-shift-c": "project_panel::CopyRelativePath",
|
||||
"f2": "project_panel::Rename",
|
||||
"backspace": "project_panel::Delete",
|
||||
"alt-cmd-r": "project_panel::RevealInFinder"
|
||||
|
|
|
@ -2,8 +2,10 @@ use auto_update::{AutoUpdateStatus, AutoUpdater, DismissErrorMessage};
|
|||
use editor::Editor;
|
||||
use futures::StreamExt;
|
||||
use gpui::{
|
||||
actions, elements::*, platform::CursorStyle, Action, AppContext, Entity, ModelHandle,
|
||||
MouseButton, MutableAppContext, RenderContext, View, ViewContext, ViewHandle,
|
||||
actions,
|
||||
elements::*,
|
||||
platform::{CursorStyle, MouseButton},
|
||||
Action, AppContext, Entity, ModelHandle, RenderContext, View, ViewContext, ViewHandle,
|
||||
};
|
||||
use language::{LanguageRegistry, LanguageServerBinaryStatus};
|
||||
use project::{LanguageServerProgress, Project};
|
||||
|
@ -46,7 +48,7 @@ struct Content {
|
|||
action: Option<Box<dyn Action>>,
|
||||
}
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(ActivityIndicator::show_error_message);
|
||||
cx.add_action(ActivityIndicator::dismiss_error_message);
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ use client::{ZED_APP_PATH, ZED_APP_VERSION, ZED_SECRET_CLIENT_TOKEN};
|
|||
use db::kvp::KEY_VALUE_STORE;
|
||||
use gpui::{
|
||||
actions, platform::AppVersion, AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle,
|
||||
MutableAppContext, Task, WeakViewHandle,
|
||||
Task, WeakViewHandle,
|
||||
};
|
||||
use serde::Deserialize;
|
||||
use settings::Settings;
|
||||
|
@ -49,7 +49,7 @@ impl Entity for AutoUpdater {
|
|||
type Event = ();
|
||||
}
|
||||
|
||||
pub fn init(http_client: Arc<dyn HttpClient>, server_url: String, cx: &mut MutableAppContext) {
|
||||
pub fn init(http_client: Arc<dyn HttpClient>, server_url: String, cx: &mut AppContext) {
|
||||
if let Some(version) = (*ZED_APP_VERSION).or_else(|| cx.platform().app_version().ok()) {
|
||||
let server_url = server_url;
|
||||
let auto_updater = cx.add_model(|cx| {
|
||||
|
@ -95,7 +95,7 @@ pub fn init(http_client: Arc<dyn HttpClient>, server_url: String, cx: &mut Mutab
|
|||
|
||||
pub fn notify_of_any_new_update(
|
||||
workspace: WeakViewHandle<Workspace>,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) -> Option<()> {
|
||||
let updater = AutoUpdater::get(cx)?;
|
||||
let version = updater.read(cx).current_version;
|
||||
|
@ -124,7 +124,7 @@ pub fn notify_of_any_new_update(
|
|||
}
|
||||
|
||||
impl AutoUpdater {
|
||||
pub fn get(cx: &mut MutableAppContext) -> Option<ModelHandle<Self>> {
|
||||
pub fn get(cx: &mut AppContext) -> Option<ModelHandle<Self>> {
|
||||
cx.default_global::<Option<ModelHandle<Self>>>().clone()
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use crate::ViewReleaseNotes;
|
||||
use gpui::{
|
||||
elements::{Flex, MouseEventHandler, Padding, ParentElement, Svg, Text},
|
||||
platform::{AppVersion, CursorStyle},
|
||||
Element, Entity, MouseButton, View, ViewContext,
|
||||
platform::{AppVersion, CursorStyle, MouseButton},
|
||||
Element, Entity, View, ViewContext,
|
||||
};
|
||||
use menu::Cancel;
|
||||
use settings::Settings;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use gpui::{
|
||||
elements::*, AppContext, Entity, MouseButton, RenderContext, Subscription, View, ViewContext,
|
||||
ViewHandle,
|
||||
elements::*, platform::MouseButton, AppContext, Entity, RenderContext, Subscription, View,
|
||||
ViewContext, ViewHandle,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use search::ProjectSearchView;
|
||||
|
@ -136,7 +136,7 @@ impl ToolbarItemView for Breadcrumbs {
|
|||
}
|
||||
}
|
||||
|
||||
fn pane_focus_update(&mut self, pane_focused: bool, _: &mut gpui::MutableAppContext) {
|
||||
fn pane_focus_update(&mut self, pane_focused: bool, _: &mut gpui::AppContext) {
|
||||
self.pane_focused = pane_focused;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,15 +10,15 @@ use futures::{future::Shared, FutureExt};
|
|||
use postage::watch;
|
||||
|
||||
use gpui::{
|
||||
AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, MutableAppContext,
|
||||
Subscription, Task, WeakModelHandle,
|
||||
AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, Subscription, Task,
|
||||
WeakModelHandle,
|
||||
};
|
||||
use project::Project;
|
||||
|
||||
pub use participant::ParticipantLocation;
|
||||
pub use room::Room;
|
||||
|
||||
pub fn init(client: Arc<Client>, user_store: ModelHandle<UserStore>, cx: &mut MutableAppContext) {
|
||||
pub fn init(client: Arc<Client>, user_store: ModelHandle<UserStore>, cx: &mut AppContext) {
|
||||
let active_call = cx.add_model(|cx| ActiveCall::new(client, user_store, cx));
|
||||
cx.set_global(active_call);
|
||||
}
|
||||
|
|
|
@ -10,9 +10,7 @@ use client::{
|
|||
use collections::{BTreeMap, HashMap, HashSet};
|
||||
use fs::Fs;
|
||||
use futures::{FutureExt, StreamExt};
|
||||
use gpui::{
|
||||
AsyncAppContext, Entity, ModelContext, ModelHandle, MutableAppContext, Task, WeakModelHandle,
|
||||
};
|
||||
use gpui::{AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, Task, WeakModelHandle};
|
||||
use language::LanguageRegistry;
|
||||
use live_kit_client::{LocalTrackPublication, LocalVideoTrack, RemoteVideoTrackUpdate};
|
||||
use postage::stream::Stream;
|
||||
|
@ -64,16 +62,13 @@ pub struct Room {
|
|||
impl Entity for Room {
|
||||
type Event = Event;
|
||||
|
||||
fn release(&mut self, cx: &mut MutableAppContext) {
|
||||
fn release(&mut self, cx: &mut AppContext) {
|
||||
if self.status.is_online() {
|
||||
self.leave_internal(cx).detach_and_log_err(cx);
|
||||
}
|
||||
}
|
||||
|
||||
fn app_will_quit(
|
||||
&mut self,
|
||||
cx: &mut MutableAppContext,
|
||||
) -> Option<Pin<Box<dyn Future<Output = ()>>>> {
|
||||
fn app_will_quit(&mut self, cx: &mut AppContext) -> Option<Pin<Box<dyn Future<Output = ()>>>> {
|
||||
if self.status.is_online() {
|
||||
let leave = self.leave_internal(cx);
|
||||
Some(
|
||||
|
@ -176,7 +171,7 @@ impl Room {
|
|||
initial_project: Option<ModelHandle<Project>>,
|
||||
client: Arc<Client>,
|
||||
user_store: ModelHandle<UserStore>,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) -> Task<Result<ModelHandle<Self>>> {
|
||||
cx.spawn(|mut cx| async move {
|
||||
let response = client.request(proto::CreateRoom {}).await?;
|
||||
|
@ -219,7 +214,7 @@ impl Room {
|
|||
call: &IncomingCall,
|
||||
client: Arc<Client>,
|
||||
user_store: ModelHandle<UserStore>,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) -> Task<Result<ModelHandle<Self>>> {
|
||||
let room_id = call.room_id;
|
||||
cx.spawn(|mut cx| async move {
|
||||
|
@ -257,7 +252,7 @@ impl Room {
|
|||
self.leave_internal(cx)
|
||||
}
|
||||
|
||||
fn leave_internal(&mut self, cx: &mut MutableAppContext) -> Task<Result<()>> {
|
||||
fn leave_internal(&mut self, cx: &mut AppContext) -> Task<Result<()>> {
|
||||
if self.status.is_offline() {
|
||||
return Task::ready(Err(anyhow!("room is offline")));
|
||||
}
|
||||
|
|
|
@ -16,9 +16,10 @@ use futures::{
|
|||
};
|
||||
use gpui::{
|
||||
actions,
|
||||
platform::AppVersion,
|
||||
serde_json::{self, Value},
|
||||
AnyModelHandle, AnyViewHandle, AnyWeakModelHandle, AnyWeakViewHandle, AppContext, AppVersion,
|
||||
AsyncAppContext, Entity, ModelHandle, MutableAppContext, Task, View, ViewContext, ViewHandle,
|
||||
AnyModelHandle, AnyViewHandle, AnyWeakModelHandle, AnyWeakViewHandle, AppContext,
|
||||
AsyncAppContext, Entity, ModelHandle, Task, View, ViewContext, ViewHandle,
|
||||
};
|
||||
use lazy_static::lazy_static;
|
||||
use parking_lot::RwLock;
|
||||
|
@ -70,7 +71,7 @@ pub const CONNECTION_TIMEOUT: Duration = Duration::from_secs(5);
|
|||
|
||||
actions!(client, [SignIn, SignOut]);
|
||||
|
||||
pub fn init(client: Arc<Client>, cx: &mut MutableAppContext) {
|
||||
pub fn init(client: Arc<Client>, cx: &mut AppContext) {
|
||||
cx.add_global_action({
|
||||
let client = client.clone();
|
||||
move |_: &SignIn, cx| {
|
||||
|
|
|
@ -15,8 +15,9 @@ use gpui::{
|
|||
geometry::{rect::RectF, vector::vec2f, PathBuilder},
|
||||
impl_internal_actions,
|
||||
json::{self, ToJson},
|
||||
CursorStyle, Entity, ImageData, ModelHandle, MouseButton, MutableAppContext, RenderContext,
|
||||
Subscription, View, ViewContext, ViewHandle, WeakViewHandle,
|
||||
platform::{CursorStyle, MouseButton},
|
||||
AppContext, Entity, ImageData, ModelHandle, RenderContext, Subscription, View, ViewContext,
|
||||
ViewHandle, WeakViewHandle,
|
||||
};
|
||||
use settings::Settings;
|
||||
use std::{ops::Range, sync::Arc};
|
||||
|
@ -40,7 +41,7 @@ impl_internal_actions!(collab, [LeaveCall]);
|
|||
#[derive(Copy, Clone, PartialEq)]
|
||||
pub(crate) struct LeaveCall;
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(CollabTitlebarItem::toggle_collaborator_list_popover);
|
||||
cx.add_action(CollabTitlebarItem::toggle_contacts_popover);
|
||||
cx.add_action(CollabTitlebarItem::share_project);
|
||||
|
|
|
@ -13,13 +13,13 @@ mod sharing_status_indicator;
|
|||
use anyhow::anyhow;
|
||||
use call::ActiveCall;
|
||||
pub use collab_titlebar_item::{CollabTitlebarItem, ToggleContactsMenu};
|
||||
use gpui::{actions, MutableAppContext, Task};
|
||||
use gpui::{actions, AppContext, Task};
|
||||
use std::sync::Arc;
|
||||
use workspace::{AppState, JoinProject, ToggleFollow, Workspace};
|
||||
|
||||
actions!(collab, [ToggleScreenSharing]);
|
||||
|
||||
pub fn init(app_state: Arc<AppState>, cx: &mut MutableAppContext) {
|
||||
pub fn init(app_state: Arc<AppState>, cx: &mut AppContext) {
|
||||
collab_titlebar_item::init(cx);
|
||||
contact_notification::init(cx);
|
||||
contact_list::init(cx);
|
||||
|
@ -35,7 +35,7 @@ pub fn init(app_state: Arc<AppState>, cx: &mut MutableAppContext) {
|
|||
});
|
||||
}
|
||||
|
||||
pub fn toggle_screen_sharing(_: &ToggleScreenSharing, cx: &mut MutableAppContext) {
|
||||
pub fn toggle_screen_sharing(_: &ToggleScreenSharing, cx: &mut AppContext) {
|
||||
if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() {
|
||||
let toggle_screen_sharing = room.update(cx, |room, cx| {
|
||||
if room.is_screen_sharing() {
|
||||
|
@ -48,13 +48,13 @@ pub fn toggle_screen_sharing(_: &ToggleScreenSharing, cx: &mut MutableAppContext
|
|||
}
|
||||
}
|
||||
|
||||
fn join_project(action: &JoinProject, app_state: Arc<AppState>, cx: &mut MutableAppContext) {
|
||||
fn join_project(action: &JoinProject, app_state: Arc<AppState>, cx: &mut AppContext) {
|
||||
let project_id = action.project_id;
|
||||
let follow_user_id = action.follow_user_id;
|
||||
cx.spawn(|mut cx| async move {
|
||||
let existing_workspace = cx.update(|cx| {
|
||||
cx.window_ids()
|
||||
.filter_map(|window_id| cx.root_view::<Workspace>(window_id))
|
||||
.filter_map(|window_id| cx.root_view(window_id)?.clone().downcast::<Workspace>())
|
||||
.find(|workspace| {
|
||||
workspace.read(cx).project().read(cx).remote_id() == Some(project_id)
|
||||
})
|
||||
|
|
|
@ -2,7 +2,8 @@ use call::ActiveCall;
|
|||
use client::UserStore;
|
||||
use gpui::Action;
|
||||
use gpui::{
|
||||
actions, elements::*, Entity, ModelHandle, MouseButton, RenderContext, View, ViewContext,
|
||||
actions, elements::*, platform::MouseButton, Entity, ModelHandle, RenderContext, View,
|
||||
ViewContext,
|
||||
};
|
||||
use settings::Settings;
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
use client::{ContactRequestStatus, User, UserStore};
|
||||
use gpui::{
|
||||
elements::*, AnyViewHandle, AppContext, Entity, ModelHandle, MouseState, MutableAppContext,
|
||||
RenderContext, Task, View, ViewContext, ViewHandle,
|
||||
elements::*, AnyViewHandle, AppContext, Entity, ModelHandle, MouseState, RenderContext, Task,
|
||||
View, ViewContext, ViewHandle,
|
||||
};
|
||||
use picker::{Picker, PickerDelegate};
|
||||
use settings::Settings;
|
||||
use std::sync::Arc;
|
||||
use util::TryFutureExt;
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
Picker::<ContactFinder>::init(cx);
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ use gpui::{
|
|||
geometry::{rect::RectF, vector::vec2f},
|
||||
impl_actions, impl_internal_actions,
|
||||
keymap_matcher::KeymapContext,
|
||||
AppContext, CursorStyle, Entity, ModelHandle, MouseButton, MutableAppContext, PromptLevel,
|
||||
RenderContext, Subscription, View, ViewContext, ViewHandle,
|
||||
platform::{CursorStyle, MouseButton, PromptLevel},
|
||||
AppContext, Entity, ModelHandle, RenderContext, Subscription, View, ViewContext, ViewHandle,
|
||||
};
|
||||
use menu::{Confirm, SelectNext, SelectPrev};
|
||||
use project::Project;
|
||||
|
@ -24,7 +24,7 @@ use workspace::{JoinProject, OpenSharedScreen};
|
|||
impl_actions!(contact_list, [RemoveContact, RespondToContactRequest]);
|
||||
impl_internal_actions!(contact_list, [ToggleExpanded, Call]);
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(ContactList::remove_contact);
|
||||
cx.add_action(ContactList::respond_to_contact_request);
|
||||
cx.add_action(ContactList::cancel);
|
||||
|
|
|
@ -3,14 +3,14 @@ use std::sync::Arc;
|
|||
use crate::notifications::render_user_notification;
|
||||
use client::{ContactEventKind, User, UserStore};
|
||||
use gpui::{
|
||||
elements::*, impl_internal_actions, Entity, ModelHandle, MutableAppContext, RenderContext,
|
||||
View, ViewContext,
|
||||
elements::*, impl_internal_actions, AppContext, Entity, ModelHandle, RenderContext, View,
|
||||
ViewContext,
|
||||
};
|
||||
use workspace::notifications::Notification;
|
||||
|
||||
impl_internal_actions!(contact_notifications, [Dismiss, RespondToContactRequest]);
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(ContactNotification::dismiss);
|
||||
cx.add_action(ContactNotification::respond_to_contact_request);
|
||||
}
|
||||
|
|
|
@ -1,15 +1,15 @@
|
|||
use crate::{contact_finder::ContactFinder, contact_list::ContactList, ToggleContactsMenu};
|
||||
use client::UserStore;
|
||||
use gpui::{
|
||||
actions, elements::*, Entity, ModelHandle, MouseButton, MutableAppContext, RenderContext, View,
|
||||
ViewContext, ViewHandle,
|
||||
actions, elements::*, platform::MouseButton, AppContext, Entity, ModelHandle, RenderContext,
|
||||
View, ViewContext, ViewHandle,
|
||||
};
|
||||
use project::Project;
|
||||
use settings::Settings;
|
||||
|
||||
actions!(contacts_popover, [ToggleContactFinder]);
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(ContactsPopover::toggle_contact_finder);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,9 @@ use futures::StreamExt;
|
|||
use gpui::{
|
||||
elements::*,
|
||||
geometry::{rect::RectF, vector::vec2f},
|
||||
impl_internal_actions, CursorStyle, Entity, MouseButton, MutableAppContext, RenderContext,
|
||||
View, ViewContext, WindowBounds, WindowKind, WindowOptions,
|
||||
impl_internal_actions,
|
||||
platform::{CursorStyle, MouseButton, WindowBounds, WindowKind, WindowOptions},
|
||||
AppContext, Entity, RenderContext, View, ViewContext,
|
||||
};
|
||||
use settings::Settings;
|
||||
use util::ResultExt;
|
||||
|
@ -13,7 +14,7 @@ use workspace::JoinProject;
|
|||
|
||||
impl_internal_actions!(incoming_call_notification, [RespondToCall]);
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(IncomingCallNotification::respond_to_call);
|
||||
|
||||
let mut incoming_call = ActiveCall::global(cx).read(cx).incoming();
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use client::User;
|
||||
use gpui::{
|
||||
elements::*, platform::CursorStyle, Action, Element, ElementBox, MouseButton, RenderContext,
|
||||
View,
|
||||
elements::*,
|
||||
platform::{CursorStyle, MouseButton},
|
||||
Action, Element, ElementBox, RenderContext, View,
|
||||
};
|
||||
use settings::Settings;
|
||||
use std::sync::Arc;
|
||||
|
|
|
@ -5,8 +5,8 @@ use gpui::{
|
|||
actions,
|
||||
elements::*,
|
||||
geometry::{rect::RectF, vector::vec2f},
|
||||
CursorStyle, Entity, MouseButton, MutableAppContext, RenderContext, View, ViewContext,
|
||||
WindowBounds, WindowKind, WindowOptions,
|
||||
platform::{CursorStyle, MouseButton, WindowBounds, WindowKind, WindowOptions},
|
||||
AppContext, Entity, RenderContext, View, ViewContext,
|
||||
};
|
||||
use settings::Settings;
|
||||
use std::sync::Arc;
|
||||
|
@ -14,7 +14,7 @@ use workspace::JoinProject;
|
|||
|
||||
actions!(project_shared_notification, [DismissProject]);
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(ProjectSharedNotification::join);
|
||||
cx.add_action(ProjectSharedNotification::dismiss);
|
||||
|
||||
|
|
|
@ -2,13 +2,14 @@ use call::ActiveCall;
|
|||
use gpui::{
|
||||
color::Color,
|
||||
elements::{MouseEventHandler, Svg},
|
||||
Appearance, Element, ElementBox, Entity, MouseButton, MutableAppContext, RenderContext, View,
|
||||
platform::{Appearance, MouseButton},
|
||||
AppContext, Element, ElementBox, Entity, RenderContext, View,
|
||||
};
|
||||
use settings::Settings;
|
||||
|
||||
use crate::ToggleScreenSharing;
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
let active_call = ActiveCall::global(cx);
|
||||
|
||||
let mut status_indicator = None;
|
||||
|
|
|
@ -4,7 +4,7 @@ use gpui::{
|
|||
actions,
|
||||
elements::{ChildView, Flex, Label, ParentElement},
|
||||
keymap_matcher::Keystroke,
|
||||
Action, AnyViewHandle, Element, Entity, MouseState, MutableAppContext, RenderContext, View,
|
||||
Action, AnyViewHandle, AppContext, Element, Entity, MouseState, RenderContext, View,
|
||||
ViewContext, ViewHandle,
|
||||
};
|
||||
use picker::{Picker, PickerDelegate};
|
||||
|
@ -12,7 +12,7 @@ use settings::Settings;
|
|||
use std::cmp;
|
||||
use workspace::Workspace;
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(CommandPalette::toggle);
|
||||
Picker::<CommandPalette>::init(cx);
|
||||
}
|
||||
|
|
|
@ -1,20 +1,24 @@
|
|||
use gpui::{
|
||||
elements::*, geometry::vector::Vector2F, impl_internal_actions, keymap_matcher::KeymapContext,
|
||||
platform::CursorStyle, Action, AnyViewHandle, AppContext, Axis, Entity, MouseButton,
|
||||
MouseState, MutableAppContext, RenderContext, SizeConstraint, Subscription, View, ViewContext,
|
||||
elements::*,
|
||||
geometry::vector::Vector2F,
|
||||
impl_internal_actions,
|
||||
keymap_matcher::KeymapContext,
|
||||
platform::{CursorStyle, MouseButton},
|
||||
Action, AnyViewHandle, AppContext, Axis, Entity, MouseState, RenderContext, SizeConstraint,
|
||||
Subscription, View, ViewContext,
|
||||
};
|
||||
use menu::*;
|
||||
use settings::Settings;
|
||||
use std::{any::TypeId, borrow::Cow, time::Duration};
|
||||
|
||||
pub type StaticItem = Box<dyn Fn(&mut MutableAppContext) -> ElementBox>;
|
||||
pub type StaticItem = Box<dyn Fn(&mut AppContext) -> ElementBox>;
|
||||
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
struct Clicked;
|
||||
|
||||
impl_internal_actions!(context_menu, [Clicked]);
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(ContextMenu::select_first);
|
||||
cx.add_action(ContextMenu::select_last);
|
||||
cx.add_action(ContextMenu::select_next);
|
||||
|
|
|
@ -6,10 +6,7 @@ use async_compression::futures::bufread::GzipDecoder;
|
|||
use async_tar::Archive;
|
||||
use collections::HashMap;
|
||||
use futures::{future::Shared, Future, FutureExt, TryFutureExt};
|
||||
use gpui::{
|
||||
actions, AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, MutableAppContext,
|
||||
Task,
|
||||
};
|
||||
use gpui::{actions, AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, Task};
|
||||
use language::{point_from_lsp, point_to_lsp, Anchor, Bias, Buffer, Language, ToPointUtf16};
|
||||
use log::{debug, error};
|
||||
use lsp::LanguageServer;
|
||||
|
@ -34,7 +31,7 @@ actions!(copilot_auth, [SignIn, SignOut]);
|
|||
const COPILOT_NAMESPACE: &'static str = "copilot";
|
||||
actions!(copilot, [NextSuggestion, PreviousSuggestion, Reinstall]);
|
||||
|
||||
pub fn init(http: Arc<dyn HttpClient>, node_runtime: Arc<NodeRuntime>, cx: &mut MutableAppContext) {
|
||||
pub fn init(http: Arc<dyn HttpClient>, node_runtime: Arc<NodeRuntime>, cx: &mut AppContext) {
|
||||
// Disable Copilot for stable releases.
|
||||
if *cx.global::<ReleaseChannel>() == ReleaseChannel::Stable {
|
||||
cx.update_global::<collections::CommandPaletteFilter, _, _>(|filter, _cx| {
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
use crate::{request::PromptUserDeviceFlow, Copilot, Status};
|
||||
use gpui::{
|
||||
elements::*, geometry::rect::RectF, ClipboardItem, Element, Entity, MutableAppContext, View,
|
||||
ViewContext, ViewHandle, WindowKind, WindowOptions,
|
||||
elements::*,
|
||||
geometry::rect::RectF,
|
||||
platform::{WindowBounds, WindowKind, WindowOptions},
|
||||
AppContext, ClipboardItem, Element, Entity, View, ViewContext, ViewHandle,
|
||||
};
|
||||
use settings::Settings;
|
||||
use theme::ui::modal;
|
||||
|
@ -14,7 +16,7 @@ struct OpenGithub;
|
|||
|
||||
const COPILOT_SIGN_UP_URL: &'static str = "https://github.com/features/copilot";
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
let copilot = Copilot::global(cx).unwrap();
|
||||
|
||||
let mut code_verification: Option<ViewHandle<CopilotCodeVerification>> = None;
|
||||
|
@ -57,13 +59,13 @@ pub fn init(cx: &mut MutableAppContext) {
|
|||
}
|
||||
|
||||
fn create_copilot_auth_window(
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
status: &Status,
|
||||
code_verification: &mut Option<ViewHandle<CopilotCodeVerification>>,
|
||||
) {
|
||||
let window_size = cx.global::<Settings>().theme.copilot.modal.dimensions();
|
||||
let window_options = WindowOptions {
|
||||
bounds: gpui::WindowBounds::Fixed(RectF::new(Default::default(), window_size)),
|
||||
bounds: WindowBounds::Fixed(RectF::new(Default::default(), window_size)),
|
||||
titlebar: None,
|
||||
center: true,
|
||||
focus: true,
|
||||
|
@ -128,7 +130,7 @@ impl CopilotCodeVerification {
|
|||
.with_style(device_code_style.cta.style_for(state, false).container)
|
||||
.boxed()
|
||||
})
|
||||
.on_click(gpui::MouseButton::Left, {
|
||||
.on_click(gpui::platform::MouseButton::Left, {
|
||||
let user_code = data.user_code.clone();
|
||||
move |_, cx| {
|
||||
cx.platform()
|
||||
|
@ -136,7 +138,7 @@ impl CopilotCodeVerification {
|
|||
cx.notify();
|
||||
}
|
||||
})
|
||||
.with_cursor_style(gpui::CursorStyle::PointingHand)
|
||||
.with_cursor_style(gpui::platform::CursorStyle::PointingHand)
|
||||
.boxed()
|
||||
}
|
||||
|
||||
|
|
|
@ -3,8 +3,11 @@ use std::sync::Arc;
|
|||
use context_menu::{ContextMenu, ContextMenuItem};
|
||||
use editor::Editor;
|
||||
use gpui::{
|
||||
elements::*, impl_internal_actions, CursorStyle, Element, ElementBox, Entity, MouseButton,
|
||||
MouseState, MutableAppContext, RenderContext, Subscription, View, ViewContext, ViewHandle,
|
||||
elements::*,
|
||||
impl_internal_actions,
|
||||
platform::{CursorStyle, MouseButton},
|
||||
AppContext, Element, ElementBox, Entity, MouseState, RenderContext, Subscription, View,
|
||||
ViewContext, ViewHandle,
|
||||
};
|
||||
use settings::{settings_file::SettingsFile, Settings};
|
||||
use workspace::{
|
||||
|
@ -43,7 +46,7 @@ impl_internal_actions!(
|
|||
]
|
||||
);
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(CopilotButton::deploy_copilot_menu);
|
||||
cx.add_action(
|
||||
|_: &mut CopilotButton, action: &ToggleCopilotForLanguage, cx| {
|
||||
|
|
|
@ -4,7 +4,7 @@ pub mod query;
|
|||
// Re-export
|
||||
pub use anyhow;
|
||||
use anyhow::Context;
|
||||
use gpui::MutableAppContext;
|
||||
use gpui::AppContext;
|
||||
pub use indoc::indoc;
|
||||
pub use lazy_static;
|
||||
use parking_lot::{Mutex, RwLock};
|
||||
|
@ -239,7 +239,7 @@ macro_rules! define_connection {
|
|||
};
|
||||
}
|
||||
|
||||
pub fn write_and_log<F>(cx: &mut MutableAppContext, db_write: impl FnOnce() -> F + Send + 'static)
|
||||
pub fn write_and_log<F>(cx: &mut AppContext, db_write: impl FnOnce() -> F + Send + 'static)
|
||||
where
|
||||
F: Future<Output = anyhow::Result<()>> + Send,
|
||||
{
|
||||
|
|
|
@ -11,8 +11,8 @@ use editor::{
|
|||
};
|
||||
use gpui::{
|
||||
actions, elements::*, fonts::TextStyle, impl_internal_actions, serde_json, AnyViewHandle,
|
||||
AppContext, Entity, ModelHandle, MutableAppContext, RenderContext, Task, View, ViewContext,
|
||||
ViewHandle, WeakViewHandle,
|
||||
AppContext, Entity, ModelHandle, RenderContext, Task, View, ViewContext, ViewHandle,
|
||||
WeakViewHandle,
|
||||
};
|
||||
use language::{
|
||||
Anchor, Bias, Buffer, Diagnostic, DiagnosticEntry, DiagnosticSeverity, Point, Selection,
|
||||
|
@ -41,7 +41,7 @@ impl_internal_actions!(diagnostics, [Jump]);
|
|||
|
||||
const CONTEXT_LINE_COUNT: u32 = 1;
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(ProjectDiagnosticsEditor::deploy);
|
||||
items::init(cx);
|
||||
}
|
||||
|
@ -1176,10 +1176,7 @@ mod tests {
|
|||
});
|
||||
}
|
||||
|
||||
fn editor_blocks(
|
||||
editor: &ViewHandle<Editor>,
|
||||
cx: &mut MutableAppContext,
|
||||
) -> Vec<(u32, String)> {
|
||||
fn editor_blocks(editor: &ViewHandle<Editor>, cx: &mut AppContext) -> Vec<(u32, String)> {
|
||||
let mut presenter = cx.build_presenter(editor.id(), 0., Default::default());
|
||||
let mut cx = presenter.build_layout_context(Default::default(), false, cx);
|
||||
cx.render(editor, |editor, cx| {
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
use collections::HashSet;
|
||||
use editor::{Editor, GoToDiagnostic};
|
||||
use gpui::{
|
||||
elements::*, platform::CursorStyle, serde_json, Entity, ModelHandle, MouseButton,
|
||||
MutableAppContext, RenderContext, Subscription, View, ViewContext, ViewHandle, WeakViewHandle,
|
||||
elements::*,
|
||||
platform::{CursorStyle, MouseButton},
|
||||
serde_json, AppContext, Entity, ModelHandle, RenderContext, Subscription, View, ViewContext,
|
||||
ViewHandle, WeakViewHandle,
|
||||
};
|
||||
use language::Diagnostic;
|
||||
use project::Project;
|
||||
|
@ -17,7 +19,7 @@ pub struct DiagnosticIndicator {
|
|||
_observe_active_editor: Option<Subscription>,
|
||||
}
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(DiagnosticIndicator::go_to_next_diagnostic);
|
||||
}
|
||||
|
||||
|
|
|
@ -4,9 +4,9 @@ use collections::HashSet;
|
|||
use gpui::{
|
||||
elements::{Empty, MouseEventHandler, Overlay},
|
||||
geometry::{rect::RectF, vector::Vector2F},
|
||||
platform::{CursorStyle, MouseButton},
|
||||
scene::{MouseDown, MouseDrag},
|
||||
CursorStyle, Element, ElementBox, EventContext, MouseButton, MutableAppContext, RenderContext,
|
||||
View, WeakViewHandle,
|
||||
AppContext, Element, ElementBox, EventContext, RenderContext, View, WeakViewHandle,
|
||||
};
|
||||
|
||||
const DEAD_ZONE: f32 = 4.;
|
||||
|
@ -261,7 +261,7 @@ impl<V: View> DragAndDrop<V> {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn cancel_dragging<P: Any>(&mut self, cx: &mut MutableAppContext) {
|
||||
pub fn cancel_dragging<P: Any>(&mut self, cx: &mut AppContext) {
|
||||
if let Some(State::Dragging {
|
||||
payload, window_id, ..
|
||||
}) = &self.currently_dragged
|
||||
|
@ -274,13 +274,13 @@ impl<V: View> DragAndDrop<V> {
|
|||
}
|
||||
}
|
||||
|
||||
fn finish_dragging(&mut self, cx: &mut MutableAppContext) {
|
||||
fn finish_dragging(&mut self, cx: &mut AppContext) {
|
||||
if let Some(State::Dragging { window_id, .. }) = self.currently_dragged.take() {
|
||||
self.notify_containers_for_window(window_id, cx);
|
||||
}
|
||||
}
|
||||
|
||||
fn notify_containers_for_window(&mut self, window_id: usize, cx: &mut MutableAppContext) {
|
||||
fn notify_containers_for_window(&mut self, window_id: usize, cx: &mut AppContext) {
|
||||
self.containers.retain(|container| {
|
||||
if let Some(container) = container.upgrade(cx) {
|
||||
if container.window_id() == window_id {
|
||||
|
|
|
@ -843,7 +843,7 @@ pub fn next_rows(display_row: u32, display_map: &DisplaySnapshot) -> impl Iterat
|
|||
pub mod tests {
|
||||
use super::*;
|
||||
use crate::{movement, test::marked_display_snapshot};
|
||||
use gpui::{color::Color, elements::*, test::observe, MutableAppContext};
|
||||
use gpui::{color::Color, elements::*, test::observe, AppContext};
|
||||
use language::{Buffer, Language, LanguageConfig, SelectionGoal};
|
||||
use rand::{prelude::*, Rng};
|
||||
use smol::stream::StreamExt;
|
||||
|
@ -1117,7 +1117,7 @@ pub mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test(retries = 5)]
|
||||
fn test_soft_wraps(cx: &mut MutableAppContext) {
|
||||
fn test_soft_wraps(cx: &mut AppContext) {
|
||||
cx.foreground().set_block_on_ticks(usize::MAX..=usize::MAX);
|
||||
cx.foreground().forbid_parking();
|
||||
|
||||
|
@ -1210,7 +1210,7 @@ pub mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_text_chunks(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_text_chunks(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let text = sample_text(6, 6, 'a');
|
||||
let buffer = MultiBuffer::build_simple(&text, cx);
|
||||
|
@ -1509,9 +1509,9 @@ pub mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_clip_point(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_clip_point(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
fn assert(text: &str, shift_right: bool, bias: Bias, cx: &mut gpui::MutableAppContext) {
|
||||
fn assert(text: &str, shift_right: bool, bias: Bias, cx: &mut gpui::AppContext) {
|
||||
let (unmarked_snapshot, mut markers) = marked_display_snapshot(text, cx);
|
||||
|
||||
match bias {
|
||||
|
@ -1558,10 +1558,10 @@ pub mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_clip_at_line_ends(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_clip_at_line_ends(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
|
||||
fn assert(text: &str, cx: &mut gpui::MutableAppContext) {
|
||||
fn assert(text: &str, cx: &mut gpui::AppContext) {
|
||||
let (mut unmarked_snapshot, markers) = marked_display_snapshot(text, cx);
|
||||
unmarked_snapshot.clip_at_line_ends = true;
|
||||
assert_eq!(
|
||||
|
@ -1577,7 +1577,7 @@ pub mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_tabs_with_multibyte_chars(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_tabs_with_multibyte_chars(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let text = "✅\t\tα\nβ\t\n🏀β\t\tγ";
|
||||
let buffer = MultiBuffer::build_simple(text, cx);
|
||||
|
@ -1638,7 +1638,7 @@ pub mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_max_point(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_max_point(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple("aaa\n\t\tbbb", cx);
|
||||
let font_cache = cx.font_cache();
|
||||
|
@ -1687,7 +1687,7 @@ pub mod tests {
|
|||
rows: Range<u32>,
|
||||
map: &ModelHandle<DisplayMap>,
|
||||
theme: &'a SyntaxTheme,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) -> Vec<(String, Option<Color>)> {
|
||||
chunks(rows, map, theme, cx)
|
||||
.into_iter()
|
||||
|
@ -1699,7 +1699,7 @@ pub mod tests {
|
|||
rows: Range<u32>,
|
||||
map: &ModelHandle<DisplayMap>,
|
||||
theme: &'a SyntaxTheme,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) -> Vec<(String, Option<Color>, Option<Color>)> {
|
||||
let snapshot = map.update(cx, |map, cx| map.snapshot(cx));
|
||||
let mut chunks: Vec<(String, Option<Color>, Option<Color>)> = Vec::new();
|
||||
|
|
|
@ -1015,7 +1015,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_basic_blocks(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_basic_blocks(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
|
||||
let family_id = cx
|
||||
|
@ -1191,7 +1191,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_blocks_on_wrapped_lines(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_blocks_on_wrapped_lines(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
|
||||
let family_id = cx
|
||||
|
@ -1241,7 +1241,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test(iterations = 100)]
|
||||
fn test_random_blocks(cx: &mut gpui::MutableAppContext, mut rng: StdRng) {
|
||||
fn test_random_blocks(cx: &mut gpui::AppContext, mut rng: StdRng) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
|
||||
let operations = env::var("OPERATIONS")
|
||||
|
|
|
@ -1214,7 +1214,7 @@ mod tests {
|
|||
use Bias::{Left, Right};
|
||||
|
||||
#[gpui::test]
|
||||
fn test_basic_folds(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_basic_folds(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple(&sample_text(5, 6, 'a'), cx);
|
||||
let subscription = buffer.update(cx, |buffer, _| buffer.subscribe());
|
||||
|
@ -1287,7 +1287,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_adjacent_folds(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_adjacent_folds(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple("abcdefghijkl", cx);
|
||||
let subscription = buffer.update(cx, |buffer, _| buffer.subscribe());
|
||||
|
@ -1334,7 +1334,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_overlapping_folds(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_overlapping_folds(cx: &mut gpui::AppContext) {
|
||||
let buffer = MultiBuffer::build_simple(&sample_text(5, 6, 'a'), cx);
|
||||
let buffer_snapshot = buffer.read(cx).snapshot(cx);
|
||||
let mut map = FoldMap::new(buffer_snapshot.clone()).0;
|
||||
|
@ -1350,7 +1350,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_merging_folds_via_edit(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_merging_folds_via_edit(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple(&sample_text(5, 6, 'a'), cx);
|
||||
let subscription = buffer.update(cx, |buffer, _| buffer.subscribe());
|
||||
|
@ -1374,7 +1374,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_folds_in_range(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_folds_in_range(cx: &mut gpui::AppContext) {
|
||||
let buffer = MultiBuffer::build_simple(&sample_text(5, 6, 'a'), cx);
|
||||
let buffer_snapshot = buffer.read(cx).snapshot(cx);
|
||||
let mut map = FoldMap::new(buffer_snapshot.clone()).0;
|
||||
|
@ -1401,7 +1401,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test(iterations = 100)]
|
||||
fn test_random_folds(cx: &mut gpui::MutableAppContext, mut rng: StdRng) {
|
||||
fn test_random_folds(cx: &mut gpui::AppContext, mut rng: StdRng) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let operations = env::var("OPERATIONS")
|
||||
.map(|i| i.parse().expect("invalid `OPERATIONS` variable"))
|
||||
|
@ -1656,7 +1656,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_buffer_rows(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_buffer_rows(cx: &mut gpui::AppContext) {
|
||||
let text = sample_text(6, 6, 'a') + "\n";
|
||||
let buffer = MultiBuffer::build_simple(&text, cx);
|
||||
|
||||
|
|
|
@ -578,7 +578,7 @@ impl<'a> Iterator for SuggestionBufferRows<'a> {
|
|||
mod tests {
|
||||
use super::*;
|
||||
use crate::{display_map::fold_map::FoldMap, MultiBuffer};
|
||||
use gpui::MutableAppContext;
|
||||
use gpui::AppContext;
|
||||
use rand::{prelude::StdRng, Rng};
|
||||
use settings::Settings;
|
||||
use std::{
|
||||
|
@ -587,7 +587,7 @@ mod tests {
|
|||
};
|
||||
|
||||
#[gpui::test]
|
||||
fn test_basic(cx: &mut MutableAppContext) {
|
||||
fn test_basic(cx: &mut AppContext) {
|
||||
let buffer = MultiBuffer::build_simple("abcdefghi", cx);
|
||||
let buffer_edits = buffer.update(cx, |buffer, _| buffer.subscribe());
|
||||
let (mut fold_map, fold_snapshot) = FoldMap::new(buffer.read(cx).snapshot(cx));
|
||||
|
@ -632,7 +632,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test(iterations = 100)]
|
||||
fn test_random_suggestions(cx: &mut MutableAppContext, mut rng: StdRng) {
|
||||
fn test_random_suggestions(cx: &mut AppContext, mut rng: StdRng) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let operations = env::var("OPERATIONS")
|
||||
.map(|i| i.parse().expect("invalid `OPERATIONS` variable"))
|
||||
|
|
|
@ -578,7 +578,7 @@ mod tests {
|
|||
use rand::{prelude::StdRng, Rng};
|
||||
|
||||
#[gpui::test]
|
||||
fn test_expand_tabs(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_expand_tabs(cx: &mut gpui::AppContext) {
|
||||
let buffer = MultiBuffer::build_simple("", cx);
|
||||
let buffer_snapshot = buffer.read(cx).snapshot(cx);
|
||||
let (_, fold_snapshot) = FoldMap::new(buffer_snapshot.clone());
|
||||
|
@ -591,7 +591,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_long_lines(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_long_lines(cx: &mut gpui::AppContext) {
|
||||
let max_expansion_column = 12;
|
||||
let input = "A\tBC\tDEF\tG\tHI\tJ\tK\tL\tM";
|
||||
let output = "A BC DEF G HI J K L M";
|
||||
|
@ -640,9 +640,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_long_lines_with_character_spanning_max_expansion_column(
|
||||
cx: &mut gpui::MutableAppContext,
|
||||
) {
|
||||
fn test_long_lines_with_character_spanning_max_expansion_column(cx: &mut gpui::AppContext) {
|
||||
let max_expansion_column = 8;
|
||||
let input = "abcdefg⋯hij";
|
||||
|
||||
|
@ -657,7 +655,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test(iterations = 100)]
|
||||
fn test_random_tabs(cx: &mut gpui::MutableAppContext, mut rng: StdRng) {
|
||||
fn test_random_tabs(cx: &mut gpui::AppContext, mut rng: StdRng) {
|
||||
let tab_size = NonZeroU32::new(rng.gen_range(1..=4)).unwrap();
|
||||
let len = rng.gen_range(0..30);
|
||||
let buffer = if rng.gen() {
|
||||
|
|
|
@ -7,7 +7,7 @@ use crate::MultiBufferSnapshot;
|
|||
use gpui::{
|
||||
fonts::{FontId, HighlightStyle},
|
||||
text_layout::LineWrapper,
|
||||
Entity, ModelContext, ModelHandle, MutableAppContext, Task,
|
||||
AppContext, Entity, ModelContext, ModelHandle, Task,
|
||||
};
|
||||
use language::{Chunk, Point};
|
||||
use lazy_static::lazy_static;
|
||||
|
@ -79,7 +79,7 @@ impl WrapMap {
|
|||
font_id: FontId,
|
||||
font_size: f32,
|
||||
wrap_width: Option<f32>,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) -> (ModelHandle<Self>, WrapSnapshot) {
|
||||
let handle = cx.add_model(|cx| {
|
||||
let mut this = Self {
|
||||
|
|
|
@ -39,11 +39,10 @@ use gpui::{
|
|||
geometry::vector::Vector2F,
|
||||
impl_actions, impl_internal_actions,
|
||||
keymap_matcher::KeymapContext,
|
||||
platform::CursorStyle,
|
||||
platform::{CursorStyle, MouseButton},
|
||||
serde_json::{self, json},
|
||||
AnyViewHandle, AppContext, AsyncAppContext, ClipboardItem, Element, ElementBox, Entity,
|
||||
ModelHandle, MouseButton, MutableAppContext, RenderContext, Subscription, Task, View,
|
||||
ViewContext, ViewHandle, WeakViewHandle,
|
||||
ModelHandle, RenderContext, Subscription, Task, View, ViewContext, ViewHandle, WeakViewHandle,
|
||||
};
|
||||
use highlight_matching_bracket::refresh_matching_bracket_highlights;
|
||||
use hover_popover::{hide_hover, HideHover, HoverState};
|
||||
|
@ -261,6 +260,8 @@ actions!(
|
|||
Format,
|
||||
ToggleSoftWrap,
|
||||
RevealInFinder,
|
||||
CopyPath,
|
||||
CopyRelativePath,
|
||||
CopyHighlightJson
|
||||
]
|
||||
);
|
||||
|
@ -295,7 +296,7 @@ pub enum Direction {
|
|||
Next,
|
||||
}
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(Editor::new_file);
|
||||
cx.add_action(Editor::select);
|
||||
cx.add_action(Editor::cancel);
|
||||
|
@ -381,6 +382,8 @@ pub fn init(cx: &mut MutableAppContext) {
|
|||
cx.add_action(Editor::jump);
|
||||
cx.add_action(Editor::toggle_soft_wrap);
|
||||
cx.add_action(Editor::reveal_in_finder);
|
||||
cx.add_action(Editor::copy_path);
|
||||
cx.add_action(Editor::copy_relative_path);
|
||||
cx.add_action(Editor::copy_highlight_json);
|
||||
cx.add_async_action(Editor::format);
|
||||
cx.add_action(Editor::restart_language_server);
|
||||
|
@ -1314,7 +1317,7 @@ impl Editor {
|
|||
self.buffer().read(cx).title(cx)
|
||||
}
|
||||
|
||||
pub fn snapshot(&mut self, cx: &mut MutableAppContext) -> EditorSnapshot {
|
||||
pub fn snapshot(&mut self, cx: &mut AppContext) -> EditorSnapshot {
|
||||
EditorSnapshot {
|
||||
mode: self.mode,
|
||||
display_snapshot: self.display_map.update(cx, |map, cx| map.snapshot(cx)),
|
||||
|
@ -6168,13 +6171,13 @@ impl Editor {
|
|||
});
|
||||
}
|
||||
|
||||
pub fn longest_row(&self, cx: &mut MutableAppContext) -> u32 {
|
||||
pub fn longest_row(&self, cx: &mut AppContext) -> u32 {
|
||||
self.display_map
|
||||
.update(cx, |map, cx| map.snapshot(cx))
|
||||
.longest_row()
|
||||
}
|
||||
|
||||
pub fn max_point(&self, cx: &mut MutableAppContext) -> DisplayPoint {
|
||||
pub fn max_point(&self, cx: &mut AppContext) -> DisplayPoint {
|
||||
self.display_map
|
||||
.update(cx, |map, cx| map.snapshot(cx))
|
||||
.max_point()
|
||||
|
@ -6194,7 +6197,7 @@ impl Editor {
|
|||
});
|
||||
}
|
||||
|
||||
pub fn display_text(&self, cx: &mut MutableAppContext) -> String {
|
||||
pub fn display_text(&self, cx: &mut AppContext) -> String {
|
||||
self.display_map
|
||||
.update(cx, |map, cx| map.snapshot(cx))
|
||||
.text()
|
||||
|
@ -6226,7 +6229,7 @@ impl Editor {
|
|||
cx.notify();
|
||||
}
|
||||
|
||||
pub fn set_wrap_width(&self, width: Option<f32>, cx: &mut MutableAppContext) -> bool {
|
||||
pub fn set_wrap_width(&self, width: Option<f32>, cx: &mut AppContext) -> bool {
|
||||
self.display_map
|
||||
.update(cx, |map, cx| map.set_wrap_width(width, cx))
|
||||
}
|
||||
|
@ -6252,6 +6255,26 @@ impl Editor {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn copy_path(&mut self, _: &CopyPath, cx: &mut ViewContext<Self>) {
|
||||
if let Some(buffer) = self.buffer().read(cx).as_singleton() {
|
||||
if let Some(file) = buffer.read(cx).file().and_then(|f| f.as_local()) {
|
||||
if let Some(path) = file.abs_path(cx).to_str() {
|
||||
cx.write_to_clipboard(ClipboardItem::new(path.to_string()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn copy_relative_path(&mut self, _: &CopyRelativePath, cx: &mut ViewContext<Self>) {
|
||||
if let Some(buffer) = self.buffer().read(cx).as_singleton() {
|
||||
if let Some(file) = buffer.read(cx).file().and_then(|f| f.as_local()) {
|
||||
if let Some(path) = file.path().to_str() {
|
||||
cx.write_to_clipboard(ClipboardItem::new(path.to_string()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn highlight_rows(&mut self, rows: Option<Range<u32>>) {
|
||||
self.highlighted_rows = rows;
|
||||
}
|
||||
|
@ -6766,7 +6789,7 @@ pub struct EditorReleased(pub WeakViewHandle<Editor>);
|
|||
impl Entity for Editor {
|
||||
type Event = Event;
|
||||
|
||||
fn release(&mut self, cx: &mut MutableAppContext) {
|
||||
fn release(&mut self, cx: &mut AppContext) {
|
||||
cx.emit_global(EditorReleased(self.handle.clone()));
|
||||
}
|
||||
}
|
||||
|
@ -6842,7 +6865,7 @@ impl View for Editor {
|
|||
|
||||
fn modifiers_changed(
|
||||
&mut self,
|
||||
event: &gpui::ModifiersChangedEvent,
|
||||
event: &gpui::platform::ModifiersChangedEvent,
|
||||
cx: &mut ViewContext<Self>,
|
||||
) -> bool {
|
||||
let pending_selection = self.has_pending_selection();
|
||||
|
|
|
@ -28,7 +28,7 @@ use workspace::{
|
|||
};
|
||||
|
||||
#[gpui::test]
|
||||
fn test_edit_events(cx: &mut MutableAppContext) {
|
||||
fn test_edit_events(cx: &mut AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = cx.add_model(|cx| {
|
||||
let mut buffer = language::Buffer::new(0, "123456", cx);
|
||||
|
@ -155,7 +155,7 @@ fn test_edit_events(cx: &mut MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_undo_redo_with_selection_restoration(cx: &mut MutableAppContext) {
|
||||
fn test_undo_redo_with_selection_restoration(cx: &mut AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let mut now = Instant::now();
|
||||
let buffer = cx.add_model(|cx| language::Buffer::new(0, "123456", cx));
|
||||
|
@ -225,7 +225,7 @@ fn test_undo_redo_with_selection_restoration(cx: &mut MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_ime_composition(cx: &mut MutableAppContext) {
|
||||
fn test_ime_composition(cx: &mut AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = cx.add_model(|cx| {
|
||||
let mut buffer = language::Buffer::new(0, "abcde", cx);
|
||||
|
@ -327,7 +327,7 @@ fn test_ime_composition(cx: &mut MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_selection_with_mouse(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_selection_with_mouse(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
|
||||
let buffer = MultiBuffer::build_simple("aaaaaa\nbbbbbb\ncccccc\nddddddd\n", cx);
|
||||
|
@ -392,7 +392,7 @@ fn test_selection_with_mouse(cx: &mut gpui::MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_canceling_pending_selection(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_canceling_pending_selection(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple("aaaaaa\nbbbbbb\ncccccc\ndddddd\n", cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
|
@ -424,7 +424,7 @@ fn test_canceling_pending_selection(cx: &mut gpui::MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_clone(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_clone(cx: &mut gpui::AppContext) {
|
||||
let (text, selection_ranges) = marked_text_ranges(
|
||||
indoc! {"
|
||||
one
|
||||
|
@ -480,7 +480,7 @@ fn test_clone(cx: &mut gpui::MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_navigation_history(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_navigation_history(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
cx.set_global(DragAndDrop::<Workspace>::default());
|
||||
use workspace::item::Item;
|
||||
|
@ -492,7 +492,7 @@ fn test_navigation_history(cx: &mut gpui::MutableAppContext) {
|
|||
let handle = cx.handle();
|
||||
editor.set_nav_history(Some(pane.read(cx).nav_history_for_item(&handle)));
|
||||
|
||||
fn pop_history(editor: &mut Editor, cx: &mut MutableAppContext) -> Option<NavigationEntry> {
|
||||
fn pop_history(editor: &mut Editor, cx: &mut AppContext) -> Option<NavigationEntry> {
|
||||
editor.nav_history.as_mut().unwrap().pop_backward(cx)
|
||||
}
|
||||
|
||||
|
@ -590,7 +590,7 @@ fn test_navigation_history(cx: &mut gpui::MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_cancel(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_cancel(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple("aaaaaa\nbbbbbb\ncccccc\ndddddd\n", cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
|
@ -630,7 +630,7 @@ fn test_cancel(cx: &mut gpui::MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_fold_action(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_fold_action(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple(
|
||||
&"
|
||||
|
@ -717,7 +717,7 @@ fn test_fold_action(cx: &mut gpui::MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_move_cursor(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_move_cursor(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple(&sample_text(6, 6, 'a'), cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer.clone(), cx));
|
||||
|
@ -793,7 +793,7 @@ fn test_move_cursor(cx: &mut gpui::MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_move_cursor_multibyte(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_move_cursor_multibyte(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple("ⓐⓑⓒⓓⓔ\nabcde\nαβγδε\n", cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer.clone(), cx));
|
||||
|
@ -895,7 +895,7 @@ fn test_move_cursor_multibyte(cx: &mut gpui::MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_move_cursor_different_line_lengths(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_move_cursor_different_line_lengths(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple("ⓐⓑⓒⓓⓔ\nabcd\nαβγ\nabcd\nⓐⓑⓒⓓⓔ\n", cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer.clone(), cx));
|
||||
|
@ -942,7 +942,7 @@ fn test_move_cursor_different_line_lengths(cx: &mut gpui::MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_beginning_end_of_line(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_beginning_end_of_line(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple("abc\n def", cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
|
@ -1102,7 +1102,7 @@ fn test_beginning_end_of_line(cx: &mut gpui::MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_prev_next_word_boundary(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_prev_next_word_boundary(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple("use std::str::{foo, bar}\n\n {baz.qux()}", cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
|
@ -1151,7 +1151,7 @@ fn test_prev_next_word_boundary(cx: &mut gpui::MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_prev_next_word_bounds_with_soft_wrap(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_prev_next_word_bounds_with_soft_wrap(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple("use one::{\n two::three::four::five\n};", cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
|
@ -1330,7 +1330,7 @@ async fn test_delete_to_beginning_of_line(cx: &mut gpui::TestAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_delete_to_word_boundary(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_delete_to_word_boundary(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple("one two three four", cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer.clone(), cx));
|
||||
|
@ -1365,7 +1365,7 @@ fn test_delete_to_word_boundary(cx: &mut gpui::MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_newline(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_newline(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple("aaaa\n bbbb\n", cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer.clone(), cx));
|
||||
|
@ -1385,7 +1385,7 @@ fn test_newline(cx: &mut gpui::MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_newline_with_old_selections(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_newline_with_old_selections(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple(
|
||||
"
|
||||
|
@ -1517,7 +1517,7 @@ async fn test_newline_below(cx: &mut gpui::TestAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_insert_with_old_selections(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_insert_with_old_selections(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple("a( X ), b( Y ), c( Z )", cx);
|
||||
let (_, editor) = cx.add_window(Default::default(), |cx| {
|
||||
|
@ -1836,7 +1836,7 @@ async fn test_indent_outdent_with_hard_tabs(cx: &mut gpui::TestAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_indent_outdent_with_excerpts(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_indent_outdent_with_excerpts(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(
|
||||
Settings::test(cx)
|
||||
.with_language_defaults(
|
||||
|
@ -2022,7 +2022,7 @@ async fn test_delete(cx: &mut gpui::TestAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_delete_line(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_delete_line(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple("abc\ndef\nghi\n", cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
|
@ -2062,7 +2062,7 @@ fn test_delete_line(cx: &mut gpui::MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_duplicate_line(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_duplicate_line(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple("abc\ndef\nghi\n", cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
|
@ -2110,7 +2110,7 @@ fn test_duplicate_line(cx: &mut gpui::MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_move_line_up_down(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_move_line_up_down(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple(&sample_text(10, 5, 'a'), cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
|
@ -2206,7 +2206,7 @@ fn test_move_line_up_down(cx: &mut gpui::MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_move_line_up_down_with_blocks(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_move_line_up_down_with_blocks(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple(&sample_text(10, 5, 'a'), cx);
|
||||
let snapshot = buffer.read(cx).snapshot(cx);
|
||||
|
@ -2230,7 +2230,7 @@ fn test_move_line_up_down_with_blocks(cx: &mut gpui::MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_transpose(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_transpose(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
|
||||
_ = cx
|
||||
|
@ -2524,7 +2524,7 @@ async fn test_paste_multiline(cx: &mut gpui::TestAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_select_all(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_select_all(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple("abc\nde\nfgh", cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
|
@ -2538,7 +2538,7 @@ fn test_select_all(cx: &mut gpui::MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_select_line(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_select_line(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple(&sample_text(6, 5, 'a'), cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
|
@ -2582,7 +2582,7 @@ fn test_select_line(cx: &mut gpui::MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_split_selection_into_lines(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_split_selection_into_lines(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple(&sample_text(9, 5, 'a'), cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
|
@ -2650,7 +2650,7 @@ fn test_split_selection_into_lines(cx: &mut gpui::MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_add_selection_above_below(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_add_selection_above_below(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple("abc\ndefghi\n\njk\nlmno\n", cx);
|
||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, cx));
|
||||
|
@ -4928,7 +4928,7 @@ async fn test_toggle_block_comment(cx: &mut gpui::TestAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_editing_disjoint_excerpts(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_editing_disjoint_excerpts(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = cx.add_model(|cx| Buffer::new(0, sample_text(3, 4, 'a'), cx));
|
||||
let multibuffer = cx.add_model(|cx| {
|
||||
|
@ -4975,7 +4975,7 @@ fn test_editing_disjoint_excerpts(cx: &mut gpui::MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_editing_overlapping_excerpts(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_editing_overlapping_excerpts(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let markers = vec![('[', ']').into(), ('(', ')').into()];
|
||||
let (initial_text, mut excerpt_ranges) = marked_text_ranges_by(
|
||||
|
@ -5048,7 +5048,7 @@ fn test_editing_overlapping_excerpts(cx: &mut gpui::MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_refresh_selections(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_refresh_selections(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = cx.add_model(|cx| Buffer::new(0, sample_text(3, 4, 'a'), cx));
|
||||
let mut excerpt1_id = None;
|
||||
|
@ -5134,7 +5134,7 @@ fn test_refresh_selections(cx: &mut gpui::MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_refresh_selections_while_selecting_with_mouse(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_refresh_selections_while_selecting_with_mouse(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = cx.add_model(|cx| Buffer::new(0, sample_text(3, 4, 'a'), cx));
|
||||
let mut excerpt1_id = None;
|
||||
|
@ -5267,7 +5267,7 @@ async fn test_extra_newline_insertion(cx: &mut gpui::TestAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_highlighted_ranges(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_highlighted_ranges(cx: &mut gpui::AppContext) {
|
||||
let buffer = MultiBuffer::build_simple(&sample_text(16, 8, 'a'), cx);
|
||||
|
||||
cx.set_global(Settings::test(cx));
|
||||
|
|
|
@ -29,11 +29,10 @@ use gpui::{
|
|||
PathBuilder,
|
||||
},
|
||||
json::{self, ToJson},
|
||||
platform::CursorStyle,
|
||||
platform::{CursorStyle, Modifiers, MouseButton, MouseButtonEvent, MouseMovedEvent},
|
||||
text_layout::{self, Line, RunStyle, TextLayoutCache},
|
||||
AppContext, Axis, Border, CursorRegion, Element, ElementBox, EventContext, LayoutContext,
|
||||
Modifiers, MouseButton, MouseButtonEvent, MouseMovedEvent, MouseRegion, MutableAppContext,
|
||||
PaintContext, Quad, SceneBuilder, SizeConstraint, ViewContext, WeakViewHandle,
|
||||
MouseRegion, PaintContext, Quad, SceneBuilder, SizeConstraint, ViewContext, WeakViewHandle,
|
||||
};
|
||||
use itertools::Itertools;
|
||||
use json::json;
|
||||
|
@ -103,14 +102,14 @@ impl EditorElement {
|
|||
self.view.upgrade(cx).unwrap().read(cx)
|
||||
}
|
||||
|
||||
fn update_view<F, T>(&self, cx: &mut MutableAppContext, f: F) -> T
|
||||
fn update_view<F, T>(&self, cx: &mut AppContext, f: F) -> T
|
||||
where
|
||||
F: FnOnce(&mut Editor, &mut ViewContext<Editor>) -> T,
|
||||
{
|
||||
self.view.upgrade(cx).unwrap().update(cx, f)
|
||||
}
|
||||
|
||||
fn snapshot(&self, cx: &mut MutableAppContext) -> EditorSnapshot {
|
||||
fn snapshot(&self, cx: &mut AppContext) -> EditorSnapshot {
|
||||
self.update_view(cx, |view, cx| view.snapshot(cx))
|
||||
}
|
||||
|
||||
|
@ -2522,7 +2521,7 @@ mod tests {
|
|||
use util::test::sample_text;
|
||||
|
||||
#[gpui::test]
|
||||
fn test_layout_line_numbers(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_layout_line_numbers(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple(&sample_text(6, 6, 'a'), cx);
|
||||
let (window_id, editor) = cx.add_window(Default::default(), |cx| {
|
||||
|
@ -2542,7 +2541,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_layout_with_placeholder_text_and_blocks(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_layout_with_placeholder_text_and_blocks(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer = MultiBuffer::build_simple("", cx);
|
||||
let (window_id, editor) = cx.add_window(Default::default(), |cx| {
|
||||
|
|
|
@ -3,9 +3,8 @@ use gpui::{
|
|||
actions,
|
||||
elements::{Flex, MouseEventHandler, Padding, Text},
|
||||
impl_internal_actions,
|
||||
platform::CursorStyle,
|
||||
Axis, Element, ElementBox, ModelHandle, MouseButton, MutableAppContext, RenderContext, Task,
|
||||
ViewContext,
|
||||
platform::{CursorStyle, MouseButton},
|
||||
AppContext, Axis, Element, ElementBox, ModelHandle, RenderContext, Task, ViewContext,
|
||||
};
|
||||
use language::{Bias, DiagnosticEntry, DiagnosticSeverity};
|
||||
use project::{HoverBlock, Project};
|
||||
|
@ -36,7 +35,7 @@ pub struct HideHover;
|
|||
actions!(editor, [Hover]);
|
||||
impl_internal_actions!(editor, [HoverAt, HideHover]);
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(hover);
|
||||
cx.add_action(hover_at);
|
||||
cx.add_action(hide_hover);
|
||||
|
|
|
@ -7,8 +7,8 @@ use anyhow::{anyhow, Context, Result};
|
|||
use collections::HashSet;
|
||||
use futures::future::try_join_all;
|
||||
use gpui::{
|
||||
elements::*, geometry::vector::vec2f, AppContext, Entity, ModelHandle, MutableAppContext,
|
||||
RenderContext, Subscription, Task, View, ViewContext, ViewHandle, WeakViewHandle,
|
||||
elements::*, geometry::vector::vec2f, AppContext, Entity, ModelHandle, RenderContext,
|
||||
Subscription, Task, View, ViewContext, ViewHandle, WeakViewHandle,
|
||||
};
|
||||
use language::{
|
||||
proto::serialize_anchor as serialize_text_anchor, Bias, Buffer, OffsetRangeExt, Point,
|
||||
|
@ -48,7 +48,7 @@ impl FollowableItem for Editor {
|
|||
project: ModelHandle<Project>,
|
||||
remote_id: ViewId,
|
||||
state: &mut Option<proto::view::Variant>,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) -> Option<Task<Result<ViewHandle<Self>>>> {
|
||||
let Some(proto::view::Variant::Editor(_)) = state else { return None };
|
||||
let Some(proto::view::Variant::Editor(state)) = state.take() else { unreachable!() };
|
||||
|
@ -769,7 +769,7 @@ impl Item for Editor {
|
|||
buffer: ModelHandle<Buffer>,
|
||||
workspace_id: WorkspaceId,
|
||||
item_id: ItemId,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) {
|
||||
if let Some(file) = buffer.read(cx).file().and_then(|file| file.as_local()) {
|
||||
let path = file.abs_path(cx);
|
||||
|
@ -1161,7 +1161,7 @@ fn path_for_file<'a>(
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use gpui::MutableAppContext;
|
||||
use gpui::AppContext;
|
||||
use std::{
|
||||
path::{Path, PathBuf},
|
||||
sync::Arc,
|
||||
|
@ -1169,7 +1169,7 @@ mod tests {
|
|||
};
|
||||
|
||||
#[gpui::test]
|
||||
fn test_path_for_file(cx: &mut MutableAppContext) {
|
||||
fn test_path_for_file(cx: &mut AppContext) {
|
||||
let file = TestFile {
|
||||
path: Path::new("").into(),
|
||||
full_path: PathBuf::from(""),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use std::ops::Range;
|
||||
|
||||
use gpui::{impl_internal_actions, MutableAppContext, Task, ViewContext};
|
||||
use gpui::{impl_internal_actions, AppContext, Task, ViewContext};
|
||||
use language::{Bias, ToOffset};
|
||||
use project::LocationLink;
|
||||
use settings::Settings;
|
||||
|
@ -38,7 +38,7 @@ impl_internal_actions!(
|
|||
]
|
||||
);
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(update_go_to_definition_link);
|
||||
cx.add_action(go_to_fetched_definition);
|
||||
cx.add_action(go_to_fetched_type_definition);
|
||||
|
@ -358,7 +358,10 @@ fn go_to_fetched_definition_of_kind(
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use futures::StreamExt;
|
||||
use gpui::{Modifiers, ModifiersChangedEvent, View};
|
||||
use gpui::{
|
||||
platform::{self, Modifiers, ModifiersChangedEvent},
|
||||
View,
|
||||
};
|
||||
use indoc::indoc;
|
||||
use lsp::request::{GotoDefinition, GotoTypeDefinition};
|
||||
|
||||
|
@ -430,7 +433,7 @@ mod tests {
|
|||
// Unpress shift causes highlight to go away (normal goto-definition is not valid here)
|
||||
cx.update_editor(|editor, cx| {
|
||||
editor.modifiers_changed(
|
||||
&gpui::ModifiersChangedEvent {
|
||||
&platform::ModifiersChangedEvent {
|
||||
modifiers: Modifiers {
|
||||
cmd: true,
|
||||
..Default::default()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use context_menu::ContextMenuItem;
|
||||
use gpui::{
|
||||
elements::AnchorCorner, geometry::vector::Vector2F, impl_internal_actions, MutableAppContext,
|
||||
elements::AnchorCorner, geometry::vector::Vector2F, impl_internal_actions, AppContext,
|
||||
ViewContext,
|
||||
};
|
||||
|
||||
|
@ -17,7 +17,7 @@ pub struct DeployMouseContextMenu {
|
|||
|
||||
impl_internal_actions!(editor, [DeployMouseContextMenu]);
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(deploy_context_menu);
|
||||
}
|
||||
|
||||
|
|
|
@ -372,9 +372,9 @@ mod tests {
|
|||
use settings::Settings;
|
||||
|
||||
#[gpui::test]
|
||||
fn test_previous_word_start(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_previous_word_start(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
fn assert(marked_text: &str, cx: &mut gpui::MutableAppContext) {
|
||||
fn assert(marked_text: &str, cx: &mut gpui::AppContext) {
|
||||
let (snapshot, display_points) = marked_display_snapshot(marked_text, cx);
|
||||
assert_eq!(
|
||||
previous_word_start(&snapshot, display_points[1]),
|
||||
|
@ -399,9 +399,9 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_previous_subword_start(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_previous_subword_start(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
fn assert(marked_text: &str, cx: &mut gpui::MutableAppContext) {
|
||||
fn assert(marked_text: &str, cx: &mut gpui::AppContext) {
|
||||
let (snapshot, display_points) = marked_display_snapshot(marked_text, cx);
|
||||
assert_eq!(
|
||||
previous_subword_start(&snapshot, display_points[1]),
|
||||
|
@ -433,11 +433,11 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_find_preceding_boundary(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_find_preceding_boundary(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
fn assert(
|
||||
marked_text: &str,
|
||||
cx: &mut gpui::MutableAppContext,
|
||||
cx: &mut gpui::AppContext,
|
||||
is_boundary: impl FnMut(char, char) -> bool,
|
||||
) {
|
||||
let (snapshot, display_points) = marked_display_snapshot(marked_text, cx);
|
||||
|
@ -465,9 +465,9 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_next_word_end(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_next_word_end(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
fn assert(marked_text: &str, cx: &mut gpui::MutableAppContext) {
|
||||
fn assert(marked_text: &str, cx: &mut gpui::AppContext) {
|
||||
let (snapshot, display_points) = marked_display_snapshot(marked_text, cx);
|
||||
assert_eq!(
|
||||
next_word_end(&snapshot, display_points[0]),
|
||||
|
@ -489,9 +489,9 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_next_subword_end(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_next_subword_end(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
fn assert(marked_text: &str, cx: &mut gpui::MutableAppContext) {
|
||||
fn assert(marked_text: &str, cx: &mut gpui::AppContext) {
|
||||
let (snapshot, display_points) = marked_display_snapshot(marked_text, cx);
|
||||
assert_eq!(
|
||||
next_subword_end(&snapshot, display_points[0]),
|
||||
|
@ -522,11 +522,11 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_find_boundary(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_find_boundary(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
fn assert(
|
||||
marked_text: &str,
|
||||
cx: &mut gpui::MutableAppContext,
|
||||
cx: &mut gpui::AppContext,
|
||||
is_boundary: impl FnMut(char, char) -> bool,
|
||||
) {
|
||||
let (snapshot, display_points) = marked_display_snapshot(marked_text, cx);
|
||||
|
@ -554,9 +554,9 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_surrounding_word(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_surrounding_word(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
fn assert(marked_text: &str, cx: &mut gpui::MutableAppContext) {
|
||||
fn assert(marked_text: &str, cx: &mut gpui::AppContext) {
|
||||
let (snapshot, display_points) = marked_display_snapshot(marked_text, cx);
|
||||
assert_eq!(
|
||||
surrounding_word(&snapshot, display_points[1]),
|
||||
|
@ -575,7 +575,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_move_up_and_down_with_excerpts(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_move_up_and_down_with_excerpts(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let family_id = cx
|
||||
.font_cache()
|
||||
|
|
|
@ -1489,15 +1489,12 @@ impl MultiBuffer {
|
|||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
impl MultiBuffer {
|
||||
pub fn build_simple(text: &str, cx: &mut gpui::MutableAppContext) -> ModelHandle<Self> {
|
||||
pub fn build_simple(text: &str, cx: &mut gpui::AppContext) -> ModelHandle<Self> {
|
||||
let buffer = cx.add_model(|cx| Buffer::new(0, text, cx));
|
||||
cx.add_model(|cx| Self::singleton(buffer, cx))
|
||||
}
|
||||
|
||||
pub fn build_random(
|
||||
rng: &mut impl rand::Rng,
|
||||
cx: &mut gpui::MutableAppContext,
|
||||
) -> ModelHandle<Self> {
|
||||
pub fn build_random(rng: &mut impl rand::Rng, cx: &mut gpui::AppContext) -> ModelHandle<Self> {
|
||||
cx.add_model(|cx| {
|
||||
let mut multibuffer = MultiBuffer::new(0);
|
||||
let mutation_count = rng.gen_range(1..=5);
|
||||
|
@ -3729,7 +3726,7 @@ where
|
|||
mod tests {
|
||||
use super::*;
|
||||
use futures::StreamExt;
|
||||
use gpui::{MutableAppContext, TestAppContext};
|
||||
use gpui::{AppContext, TestAppContext};
|
||||
use language::{Buffer, Rope};
|
||||
use rand::prelude::*;
|
||||
use settings::Settings;
|
||||
|
@ -3739,7 +3736,7 @@ mod tests {
|
|||
use util::test::sample_text;
|
||||
|
||||
#[gpui::test]
|
||||
fn test_singleton(cx: &mut MutableAppContext) {
|
||||
fn test_singleton(cx: &mut AppContext) {
|
||||
let buffer = cx.add_model(|cx| Buffer::new(0, sample_text(6, 6, 'a'), cx));
|
||||
let multibuffer = cx.add_model(|cx| MultiBuffer::singleton(buffer.clone(), cx));
|
||||
|
||||
|
@ -3766,7 +3763,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_remote(cx: &mut MutableAppContext) {
|
||||
fn test_remote(cx: &mut AppContext) {
|
||||
let host_buffer = cx.add_model(|cx| Buffer::new(0, "a", cx));
|
||||
let guest_buffer = cx.add_model(|cx| {
|
||||
let state = host_buffer.read(cx).to_proto();
|
||||
|
@ -3797,7 +3794,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_excerpt_boundaries_and_clipping(cx: &mut MutableAppContext) {
|
||||
fn test_excerpt_boundaries_and_clipping(cx: &mut AppContext) {
|
||||
let buffer_1 = cx.add_model(|cx| Buffer::new(0, sample_text(6, 6, 'a'), cx));
|
||||
let buffer_2 = cx.add_model(|cx| Buffer::new(0, sample_text(6, 6, 'g'), cx));
|
||||
let multibuffer = cx.add_model(|_| MultiBuffer::new(0));
|
||||
|
@ -4021,7 +4018,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_excerpt_events(cx: &mut MutableAppContext) {
|
||||
fn test_excerpt_events(cx: &mut AppContext) {
|
||||
let buffer_1 = cx.add_model(|cx| Buffer::new(0, sample_text(10, 3, 'a'), cx));
|
||||
let buffer_2 = cx.add_model(|cx| Buffer::new(0, sample_text(10, 3, 'm'), cx));
|
||||
|
||||
|
@ -4098,7 +4095,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_push_excerpts_with_context_lines(cx: &mut MutableAppContext) {
|
||||
fn test_push_excerpts_with_context_lines(cx: &mut AppContext) {
|
||||
let buffer = cx.add_model(|cx| Buffer::new(0, sample_text(20, 3, 'a'), cx));
|
||||
let multibuffer = cx.add_model(|_| MultiBuffer::new(0));
|
||||
let anchor_ranges = multibuffer.update(cx, |multibuffer, cx| {
|
||||
|
@ -4172,7 +4169,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_empty_multibuffer(cx: &mut MutableAppContext) {
|
||||
fn test_empty_multibuffer(cx: &mut AppContext) {
|
||||
let multibuffer = cx.add_model(|_| MultiBuffer::new(0));
|
||||
|
||||
let snapshot = multibuffer.read(cx).snapshot(cx);
|
||||
|
@ -4182,7 +4179,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_singleton_multibuffer_anchors(cx: &mut MutableAppContext) {
|
||||
fn test_singleton_multibuffer_anchors(cx: &mut AppContext) {
|
||||
let buffer = cx.add_model(|cx| Buffer::new(0, "abcd", cx));
|
||||
let multibuffer = cx.add_model(|cx| MultiBuffer::singleton(buffer.clone(), cx));
|
||||
let old_snapshot = multibuffer.read(cx).snapshot(cx);
|
||||
|
@ -4202,7 +4199,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_multibuffer_anchors(cx: &mut MutableAppContext) {
|
||||
fn test_multibuffer_anchors(cx: &mut AppContext) {
|
||||
let buffer_1 = cx.add_model(|cx| Buffer::new(0, "abcd", cx));
|
||||
let buffer_2 = cx.add_model(|cx| Buffer::new(0, "efghi", cx));
|
||||
let multibuffer = cx.add_model(|cx| {
|
||||
|
@ -4260,7 +4257,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_resolving_anchors_after_replacing_their_excerpts(cx: &mut MutableAppContext) {
|
||||
fn test_resolving_anchors_after_replacing_their_excerpts(cx: &mut AppContext) {
|
||||
let buffer_1 = cx.add_model(|cx| Buffer::new(0, "abcd", cx));
|
||||
let buffer_2 = cx.add_model(|cx| Buffer::new(0, "ABCDEFGHIJKLMNOP", cx));
|
||||
let multibuffer = cx.add_model(|_| MultiBuffer::new(0));
|
||||
|
@ -4563,7 +4560,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test(iterations = 100)]
|
||||
fn test_random_multibuffer(cx: &mut MutableAppContext, mut rng: StdRng) {
|
||||
fn test_random_multibuffer(cx: &mut AppContext, mut rng: StdRng) {
|
||||
let operations = env::var("OPERATIONS")
|
||||
.map(|i| i.parse().expect("invalid `OPERATIONS` variable"))
|
||||
.unwrap_or(10);
|
||||
|
@ -4980,7 +4977,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_history(cx: &mut MutableAppContext) {
|
||||
fn test_history(cx: &mut AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let buffer_1 = cx.add_model(|cx| Buffer::new(0, "1234", cx));
|
||||
let buffer_2 = cx.add_model(|cx| Buffer::new(0, "5678", cx));
|
||||
|
|
|
@ -9,7 +9,7 @@ use std::{
|
|||
|
||||
use gpui::{
|
||||
geometry::vector::{vec2f, Vector2F},
|
||||
Axis, MutableAppContext, Task, ViewContext,
|
||||
AppContext, Axis, Task, ViewContext,
|
||||
};
|
||||
use language::{Bias, Point};
|
||||
use util::ResultExt;
|
||||
|
@ -369,7 +369,7 @@ impl Editor {
|
|||
/// Ordering::Equal => on screen
|
||||
/// Ordering::Less => above the screen
|
||||
/// Ordering::Greater => below the screen
|
||||
pub fn newest_selection_on_screen(&self, cx: &mut MutableAppContext) -> Ordering {
|
||||
pub fn newest_selection_on_screen(&self, cx: &mut AppContext) -> Ordering {
|
||||
let snapshot = self.display_map.update(cx, |map, cx| map.snapshot(cx));
|
||||
let newest_head = self
|
||||
.selections
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
use gpui::{
|
||||
actions, geometry::vector::Vector2F, impl_internal_actions, Axis, MutableAppContext,
|
||||
ViewContext,
|
||||
actions, geometry::vector::Vector2F, impl_internal_actions, AppContext, Axis, ViewContext,
|
||||
};
|
||||
use language::Bias;
|
||||
|
||||
|
@ -32,7 +31,7 @@ pub struct Scroll {
|
|||
|
||||
impl_internal_actions!(editor, [Scroll]);
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(Editor::next_screen);
|
||||
cx.add_action(Editor::scroll);
|
||||
cx.add_action(Editor::scroll_cursor_top);
|
||||
|
|
|
@ -6,7 +6,7 @@ use std::{
|
|||
};
|
||||
|
||||
use collections::HashMap;
|
||||
use gpui::{AppContext, ModelHandle, MutableAppContext};
|
||||
use gpui::{AppContext, ModelHandle};
|
||||
use itertools::Itertools;
|
||||
use language::{Bias, Point, Selection, SelectionGoal, TextDimension, ToPoint};
|
||||
use util::post_inc;
|
||||
|
@ -53,7 +53,7 @@ impl SelectionsCollection {
|
|||
}
|
||||
}
|
||||
|
||||
fn display_map(&self, cx: &mut MutableAppContext) -> DisplaySnapshot {
|
||||
fn display_map(&self, cx: &mut AppContext) -> DisplaySnapshot {
|
||||
self.display_map.update(cx, |map, cx| map.snapshot(cx))
|
||||
}
|
||||
|
||||
|
@ -136,7 +136,7 @@ impl SelectionsCollection {
|
|||
}
|
||||
|
||||
// Returns all of the selections, adjusted to take into account the selection line_mode
|
||||
pub fn all_adjusted(&self, cx: &mut MutableAppContext) -> Vec<Selection<Point>> {
|
||||
pub fn all_adjusted(&self, cx: &mut AppContext) -> Vec<Selection<Point>> {
|
||||
let mut selections = self.all::<Point>(cx);
|
||||
if self.line_mode {
|
||||
let map = self.display_map(cx);
|
||||
|
@ -151,7 +151,7 @@ impl SelectionsCollection {
|
|||
|
||||
pub fn all_adjusted_display(
|
||||
&self,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) -> (DisplaySnapshot, Vec<Selection<DisplayPoint>>) {
|
||||
if self.line_mode {
|
||||
let selections = self.all::<Point>(cx);
|
||||
|
@ -198,7 +198,7 @@ impl SelectionsCollection {
|
|||
|
||||
pub fn all_display(
|
||||
&self,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) -> (DisplaySnapshot, Vec<Selection<DisplayPoint>>) {
|
||||
let display_map = self.display_map(cx);
|
||||
let selections = self
|
||||
|
@ -224,7 +224,7 @@ impl SelectionsCollection {
|
|||
resolve(self.newest_anchor(), &self.buffer(cx))
|
||||
}
|
||||
|
||||
pub fn newest_display(&self, cx: &mut MutableAppContext) -> Selection<DisplayPoint> {
|
||||
pub fn newest_display(&self, cx: &mut AppContext) -> Selection<DisplayPoint> {
|
||||
let display_map = self.display_map(cx);
|
||||
let selection = self
|
||||
.newest_anchor()
|
||||
|
@ -279,7 +279,7 @@ impl SelectionsCollection {
|
|||
}
|
||||
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub fn display_ranges(&self, cx: &mut MutableAppContext) -> Vec<Range<DisplayPoint>> {
|
||||
pub fn display_ranges(&self, cx: &mut AppContext) -> Vec<Range<DisplayPoint>> {
|
||||
let display_map = self.display_map(cx);
|
||||
self.disjoint_anchors()
|
||||
.iter()
|
||||
|
@ -324,7 +324,7 @@ impl SelectionsCollection {
|
|||
|
||||
pub(crate) fn change_with<R>(
|
||||
&mut self,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
change: impl FnOnce(&mut MutableSelectionsCollection) -> R,
|
||||
) -> (bool, R) {
|
||||
let mut mutable_collection = MutableSelectionsCollection {
|
||||
|
@ -345,7 +345,7 @@ impl SelectionsCollection {
|
|||
pub struct MutableSelectionsCollection<'a> {
|
||||
collection: &'a mut SelectionsCollection,
|
||||
selections_changed: bool,
|
||||
cx: &'a mut MutableAppContext,
|
||||
cx: &'a mut AppContext,
|
||||
}
|
||||
|
||||
impl<'a> MutableSelectionsCollection<'a> {
|
||||
|
|
|
@ -21,7 +21,7 @@ fn init_logger() {
|
|||
// Returns a snapshot from text containing '|' character markers with the markers removed, and DisplayPoints for each one.
|
||||
pub fn marked_display_snapshot(
|
||||
text: &str,
|
||||
cx: &mut gpui::MutableAppContext,
|
||||
cx: &mut gpui::AppContext,
|
||||
) -> (DisplaySnapshot, Vec<DisplayPoint>) {
|
||||
let (unmarked_text, markers) = marked_text_offsets(text);
|
||||
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
use gpui::{elements::*, CursorStyle, Entity, MouseButton, RenderContext, View, ViewContext};
|
||||
use gpui::{
|
||||
elements::*,
|
||||
platform::{CursorStyle, MouseButton},
|
||||
Entity, RenderContext, View, ViewContext,
|
||||
};
|
||||
use settings::Settings;
|
||||
use workspace::{item::ItemHandle, StatusItemView};
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ pub mod submit_feedback_button;
|
|||
use std::sync::Arc;
|
||||
|
||||
mod system_specs;
|
||||
use gpui::{actions, impl_actions, ClipboardItem, MutableAppContext, PromptLevel, ViewContext};
|
||||
use gpui::{actions, impl_actions, platform::PromptLevel, AppContext, ClipboardItem, ViewContext};
|
||||
use serde::Deserialize;
|
||||
use system_specs::SystemSpecs;
|
||||
use workspace::{AppState, Workspace};
|
||||
|
@ -28,7 +28,7 @@ actions!(
|
|||
]
|
||||
);
|
||||
|
||||
pub fn init(app_state: Arc<AppState>, cx: &mut MutableAppContext) {
|
||||
pub fn init(app_state: Arc<AppState>, cx: &mut AppContext) {
|
||||
let system_specs = SystemSpecs::new(&cx);
|
||||
let system_specs_text = system_specs.to_string();
|
||||
|
||||
|
@ -37,7 +37,7 @@ pub fn init(app_state: Arc<AppState>, cx: &mut MutableAppContext) {
|
|||
cx.add_global_action(move |action: &OpenBrowser, cx| cx.platform().open_url(&action.url));
|
||||
|
||||
let url = format!(
|
||||
"https://github.com/zed-industries/community/issues/new?assignees=&labels=defect%2Ctriage&template=2_bug_report.yml&environment={}",
|
||||
"https://github.com/zed-industries/community/issues/new?assignees=&labels=defect%2Ctriage&template=2_bug_report.yml&environment={}",
|
||||
urlencoding::encode(&system_specs_text)
|
||||
);
|
||||
|
||||
|
|
|
@ -11,8 +11,9 @@ use futures::AsyncReadExt;
|
|||
use gpui::{
|
||||
actions,
|
||||
elements::{ChildView, Flex, Label, ParentElement, Svg},
|
||||
serde_json, AnyViewHandle, AppContext, Element, ElementBox, Entity, ModelHandle,
|
||||
MutableAppContext, PromptLevel, RenderContext, Task, View, ViewContext, ViewHandle,
|
||||
platform::PromptLevel,
|
||||
serde_json, AnyViewHandle, AppContext, Element, ElementBox, Entity, ModelHandle, RenderContext,
|
||||
Task, View, ViewContext, ViewHandle,
|
||||
};
|
||||
use isahc::Request;
|
||||
use language::Buffer;
|
||||
|
@ -35,7 +36,7 @@ const FEEDBACK_SUBMISSION_ERROR_TEXT: &str =
|
|||
|
||||
actions!(feedback, [GiveFeedback, SubmitFeedback]);
|
||||
|
||||
pub fn init(system_specs: SystemSpecs, app_state: Arc<AppState>, cx: &mut MutableAppContext) {
|
||||
pub fn init(system_specs: SystemSpecs, app_state: Arc<AppState>, cx: &mut AppContext) {
|
||||
cx.add_action({
|
||||
move |workspace: &mut Workspace, _: &GiveFeedback, cx: &mut ViewContext<Workspace>| {
|
||||
FeedbackEditor::deploy(system_specs.clone(), workspace, app_state.clone(), cx);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use gpui::{
|
||||
elements::{Flex, Label, MouseEventHandler, ParentElement, Text},
|
||||
CursorStyle, Element, ElementBox, Entity, MouseButton, RenderContext, View, ViewContext,
|
||||
ViewHandle,
|
||||
platform::{CursorStyle, MouseButton},
|
||||
Element, ElementBox, Entity, RenderContext, View, ViewContext, ViewHandle,
|
||||
};
|
||||
use settings::Settings;
|
||||
use workspace::{item::ItemHandle, ToolbarItemLocation, ToolbarItemView};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use gpui::{
|
||||
elements::{Label, MouseEventHandler},
|
||||
CursorStyle, Element, ElementBox, Entity, MouseButton, RenderContext, View, ViewContext,
|
||||
ViewHandle,
|
||||
platform::{CursorStyle, MouseButton},
|
||||
Element, ElementBox, Entity, RenderContext, View, ViewContext, ViewHandle,
|
||||
};
|
||||
use settings::Settings;
|
||||
use workspace::{item::ItemHandle, ToolbarItemLocation, ToolbarItemView};
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
use client::ZED_APP_VERSION;
|
||||
use gpui::{AppContext, AppVersion};
|
||||
use gpui::{platform::AppVersion, AppContext};
|
||||
use human_bytes::human_bytes;
|
||||
use serde::Serialize;
|
||||
use std::{env, fmt::Display};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use fuzzy::PathMatch;
|
||||
use gpui::{
|
||||
actions, elements::*, AnyViewHandle, AppContext, Entity, ModelHandle, MouseState,
|
||||
MutableAppContext, RenderContext, Task, View, ViewContext, ViewHandle,
|
||||
RenderContext, Task, View, ViewContext, ViewHandle,
|
||||
};
|
||||
use picker::{Picker, PickerDelegate};
|
||||
use project::{PathMatchCandidateSet, Project, ProjectPath, WorktreeId};
|
||||
|
@ -31,7 +31,7 @@ pub struct FileFinder {
|
|||
|
||||
actions!(file_finder, [Toggle]);
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(FileFinder::toggle);
|
||||
Picker::<FileFinder>::init(cx);
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@ use std::sync::Arc;
|
|||
|
||||
use editor::{display_map::ToDisplayPoint, scroll::autoscroll::Autoscroll, DisplayPoint, Editor};
|
||||
use gpui::{
|
||||
actions, elements::*, geometry::vector::Vector2F, AnyViewHandle, Axis, Entity,
|
||||
MutableAppContext, RenderContext, View, ViewContext, ViewHandle,
|
||||
actions, elements::*, geometry::vector::Vector2F, AnyViewHandle, AppContext, Axis, Entity,
|
||||
RenderContext, View, ViewContext, ViewHandle,
|
||||
};
|
||||
use menu::{Cancel, Confirm};
|
||||
use settings::Settings;
|
||||
|
@ -12,7 +12,7 @@ use workspace::Workspace;
|
|||
|
||||
actions!(go_to_line, [Toggle]);
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(GoToLine::toggle);
|
||||
cx.add_action(GoToLine::confirm);
|
||||
cx.add_action(GoToLine::cancel);
|
||||
|
@ -140,7 +140,7 @@ impl GoToLine {
|
|||
impl Entity for GoToLine {
|
||||
type Event = Event;
|
||||
|
||||
fn release(&mut self, cx: &mut MutableAppContext) {
|
||||
fn release(&mut self, cx: &mut AppContext) {
|
||||
let scroll_position = self.prev_scroll_position.take();
|
||||
self.active_editor.update(cx, |editor, cx| {
|
||||
editor.highlight_rows(None);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,4 +1,4 @@
|
|||
use crate::MutableAppContext;
|
||||
use crate::AppContext;
|
||||
use collections::{BTreeMap, HashMap, HashSet};
|
||||
use parking_lot::Mutex;
|
||||
use std::sync::Arc;
|
||||
|
@ -93,10 +93,10 @@ impl<K: Clone + Hash + Eq + Copy, F> CallbackCollection<K, F> {
|
|||
drop(callbacks);
|
||||
}
|
||||
|
||||
pub fn emit<C: FnMut(&mut F, &mut MutableAppContext) -> bool>(
|
||||
pub fn emit<C: FnMut(&mut F, &mut AppContext) -> bool>(
|
||||
&mut self,
|
||||
key: K,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
mut call_callback: C,
|
||||
) {
|
||||
let callbacks = self.internal.lock().callbacks.remove(&key);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{Action, App, ForegroundPlatform, MutableAppContext};
|
||||
use crate::{platform::ForegroundPlatform, Action, App, AppContext};
|
||||
|
||||
pub struct Menu<'a> {
|
||||
pub name: &'a str,
|
||||
|
@ -51,7 +51,7 @@ pub enum OsAction {
|
|||
Redo,
|
||||
}
|
||||
|
||||
impl MutableAppContext {
|
||||
impl AppContext {
|
||||
pub fn set_menus(&mut self, menus: Vec<Menu>) {
|
||||
self.foreground_platform
|
||||
.set_menus(menus, &self.keystroke_matcher);
|
||||
|
@ -77,7 +77,7 @@ pub(crate) fn setup_menu_handlers(foreground_platform: &dyn ForegroundPlatform,
|
|||
let cx = app.0.clone();
|
||||
move |action| {
|
||||
let mut cx = cx.borrow_mut();
|
||||
if let Some(main_window_id) = cx.cx.platform.main_window_id() {
|
||||
if let Some(main_window_id) = cx.platform.main_window_id() {
|
||||
if let Some(view_id) = cx.focused_view_id(main_window_id) {
|
||||
cx.handle_dispatch_action_from_effect(main_window_id, Some(view_id), action);
|
||||
return;
|
||||
|
|
|
@ -17,11 +17,14 @@ use parking_lot::{Mutex, RwLock};
|
|||
use smol::stream::StreamExt;
|
||||
|
||||
use crate::{
|
||||
executor, geometry::vector::Vector2F, keymap_matcher::Keystroke, platform, Action,
|
||||
AnyViewHandle, AppContext, Appearance, Entity, Event, FontCache, Handle, InputHandler,
|
||||
KeyDownEvent, ModelContext, ModelHandle, MutableAppContext, Platform, ReadModelWith,
|
||||
ReadViewWith, RenderContext, Task, UpdateModel, UpdateView, View, ViewContext, ViewHandle,
|
||||
WeakHandle,
|
||||
executor,
|
||||
geometry::vector::Vector2F,
|
||||
keymap_matcher::Keystroke,
|
||||
platform,
|
||||
platform::{Appearance, Event, InputHandler, KeyDownEvent, Platform},
|
||||
Action, AnyViewHandle, AppContext, Entity, FontCache, Handle, ModelContext, ModelHandle,
|
||||
ReadModelWith, ReadViewWith, RenderContext, Task, UpdateModel, UpdateView, View, ViewContext,
|
||||
ViewHandle, WeakHandle,
|
||||
};
|
||||
use collections::BTreeMap;
|
||||
|
||||
|
@ -31,7 +34,7 @@ use super::{
|
|||
|
||||
#[derive(Clone)]
|
||||
pub struct TestAppContext {
|
||||
cx: Rc<RefCell<MutableAppContext>>,
|
||||
cx: Rc<RefCell<AppContext>>,
|
||||
foreground_platform: Rc<platform::test::ForegroundPlatform>,
|
||||
condition_duration: Option<Duration>,
|
||||
pub function_name: String,
|
||||
|
@ -49,7 +52,7 @@ impl TestAppContext {
|
|||
first_entity_id: usize,
|
||||
function_name: String,
|
||||
) -> Self {
|
||||
let mut cx = MutableAppContext::new(
|
||||
let mut cx = AppContext::new(
|
||||
foreground,
|
||||
background,
|
||||
platform,
|
||||
|
@ -150,15 +153,15 @@ impl TestAppContext {
|
|||
self.cx.borrow().window_ids().collect()
|
||||
}
|
||||
|
||||
pub fn root_view<T: View>(&self, window_id: usize) -> Option<ViewHandle<T>> {
|
||||
pub fn root_view(&self, window_id: usize) -> Option<AnyViewHandle> {
|
||||
self.cx.borrow().root_view(window_id)
|
||||
}
|
||||
|
||||
pub fn read<T, F: FnOnce(&AppContext) -> T>(&self, callback: F) -> T {
|
||||
callback(self.cx.borrow().as_ref())
|
||||
callback(&*self.cx.borrow())
|
||||
}
|
||||
|
||||
pub fn update<T, F: FnOnce(&mut MutableAppContext) -> T>(&mut self, callback: F) -> T {
|
||||
pub fn update<T, F: FnOnce(&mut AppContext) -> T>(&mut self, callback: F) -> T {
|
||||
let mut state = self.cx.borrow_mut();
|
||||
// Don't increment pending flushes in order for effects to be flushed before the callback
|
||||
// completes, which is helpful in tests.
|
||||
|
@ -195,7 +198,7 @@ impl TestAppContext {
|
|||
}
|
||||
|
||||
pub fn font_cache(&self) -> Arc<FontCache> {
|
||||
self.cx.borrow().cx.font_cache.clone()
|
||||
self.cx.borrow().font_cache.clone()
|
||||
}
|
||||
|
||||
pub fn foreground_platform(&self) -> Rc<platform::test::ForegroundPlatform> {
|
||||
|
@ -203,7 +206,7 @@ impl TestAppContext {
|
|||
}
|
||||
|
||||
pub fn platform(&self) -> Arc<dyn platform::Platform> {
|
||||
self.cx.borrow().cx.platform.clone()
|
||||
self.cx.borrow().platform.clone()
|
||||
}
|
||||
|
||||
pub fn foreground(&self) -> Rc<executor::Foreground> {
|
||||
|
@ -397,7 +400,7 @@ impl ReadModelWith for TestAppContext {
|
|||
read: &mut dyn FnMut(&E, &AppContext) -> T,
|
||||
) -> T {
|
||||
let cx = self.cx.borrow();
|
||||
let cx = cx.as_ref();
|
||||
let cx = &*cx;
|
||||
read(handle.read(cx), cx)
|
||||
}
|
||||
}
|
||||
|
@ -425,7 +428,7 @@ impl ReadViewWith for TestAppContext {
|
|||
V: View,
|
||||
{
|
||||
let cx = self.cx.borrow();
|
||||
let cx = cx.as_ref();
|
||||
let cx = &*cx;
|
||||
read(handle.read(cx), cx)
|
||||
}
|
||||
}
|
||||
|
@ -514,7 +517,7 @@ impl<T: Entity> ModelHandle<T> {
|
|||
loop {
|
||||
{
|
||||
let cx = cx.borrow();
|
||||
let cx = cx.as_ref();
|
||||
let cx = &*cx;
|
||||
if predicate(
|
||||
handle
|
||||
.upgrade(cx)
|
||||
|
@ -601,7 +604,7 @@ impl<T: View> ViewHandle<T> {
|
|||
loop {
|
||||
{
|
||||
let cx = cx.borrow();
|
||||
let cx = cx.as_ref();
|
||||
let cx = &*cx;
|
||||
if predicate(
|
||||
handle
|
||||
.upgrade(cx)
|
||||
|
|
|
@ -2,10 +2,10 @@ use std::{cell::RefCell, ops::Range, rc::Rc};
|
|||
|
||||
use pathfinder_geometry::rect::RectF;
|
||||
|
||||
use crate::{AnyView, AppContext, InputHandler, MutableAppContext};
|
||||
use crate::{platform::InputHandler, AnyView, AppContext};
|
||||
|
||||
pub struct WindowInputHandler {
|
||||
pub app: Rc<RefCell<MutableAppContext>>,
|
||||
pub app: Rc<RefCell<AppContext>>,
|
||||
pub window_id: usize,
|
||||
}
|
||||
|
||||
|
@ -23,21 +23,21 @@ impl WindowInputHandler {
|
|||
let app = self.app.try_borrow().ok()?;
|
||||
|
||||
let view_id = app.focused_view_id(self.window_id)?;
|
||||
let view = app.cx.views.get(&(self.window_id, view_id))?;
|
||||
let view = app.views.get(&(self.window_id, view_id))?;
|
||||
let result = f(view.as_ref(), &app);
|
||||
Some(result)
|
||||
}
|
||||
|
||||
fn update_focused_view<T, F>(&mut self, f: F) -> Option<T>
|
||||
where
|
||||
F: FnOnce(usize, usize, &mut dyn AnyView, &mut MutableAppContext) -> T,
|
||||
F: FnOnce(usize, usize, &mut dyn AnyView, &mut AppContext) -> T,
|
||||
{
|
||||
let mut app = self.app.try_borrow_mut().ok()?;
|
||||
app.update(|app| {
|
||||
let view_id = app.focused_view_id(self.window_id)?;
|
||||
let mut view = app.cx.views.remove(&(self.window_id, view_id))?;
|
||||
let mut view = app.views.remove(&(self.window_id, view_id))?;
|
||||
let result = f(self.window_id, view_id, view.as_mut(), &mut *app);
|
||||
app.cx.views.insert((self.window_id, view_id), view);
|
||||
app.views.insert((self.window_id, view_id), view);
|
||||
Some(result)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -210,7 +210,7 @@ mod tests {
|
|||
use crate::fonts::{Properties as FontProperties, Weight};
|
||||
|
||||
#[crate::test(self)]
|
||||
fn test_layout_label_with_highlights(cx: &mut crate::MutableAppContext) {
|
||||
fn test_layout_label_with_highlights(cx: &mut crate::AppContext) {
|
||||
let default_style = TextStyle::new(
|
||||
"Menlo",
|
||||
12.,
|
||||
|
|
|
@ -630,7 +630,7 @@ mod tests {
|
|||
use std::env;
|
||||
|
||||
#[crate::test(self)]
|
||||
fn test_layout(cx: &mut crate::MutableAppContext) {
|
||||
fn test_layout(cx: &mut crate::AppContext) {
|
||||
let mut presenter = cx.build_presenter(0, 0., Default::default());
|
||||
let (_, view) = cx.add_window(Default::default(), |_| TestView);
|
||||
let constraint = SizeConstraint::new(vec2f(0., 0.), vec2f(100., 40.));
|
||||
|
@ -725,7 +725,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[crate::test(self, iterations = 10, seed = 0)]
|
||||
fn test_random(cx: &mut crate::MutableAppContext, mut rng: StdRng) {
|
||||
fn test_random(cx: &mut crate::AppContext, mut rng: StdRng) {
|
||||
let operations = env::var("OPERATIONS")
|
||||
.map(|i| i.parse().expect("invalid `OPERATIONS` variable"))
|
||||
.unwrap_or(10);
|
||||
|
|
|
@ -5,12 +5,13 @@ use crate::{
|
|||
vector::{vec2f, Vector2F},
|
||||
},
|
||||
platform::CursorStyle,
|
||||
platform::MouseButton,
|
||||
scene::{
|
||||
CursorRegion, HandlerSet, MouseClick, MouseDown, MouseDownOut, MouseDrag, MouseHover,
|
||||
MouseMove, MouseMoveOut, MouseScrollWheel, MouseUp, MouseUpOut,
|
||||
},
|
||||
DebugContext, Element, ElementBox, EventContext, LayoutContext, MeasurementContext,
|
||||
MouseButton, MouseRegion, MouseState, PaintContext, RenderContext, SizeConstraint, View,
|
||||
MouseRegion, MouseState, PaintContext, RenderContext, SizeConstraint, View,
|
||||
};
|
||||
use serde_json::json;
|
||||
use std::{marker::PhantomData, ops::Range};
|
||||
|
|
|
@ -4,8 +4,10 @@ use pathfinder_geometry::vector::{vec2f, Vector2F};
|
|||
use serde_json::json;
|
||||
|
||||
use crate::{
|
||||
geometry::rect::RectF, scene::MouseDrag, Axis, CursorStyle, Element, ElementBox,
|
||||
ElementStateHandle, MouseButton, MouseRegion, RenderContext, View,
|
||||
geometry::rect::RectF,
|
||||
platform::{CursorStyle, MouseButton},
|
||||
scene::MouseDrag,
|
||||
Axis, Element, ElementBox, ElementStateHandle, MouseRegion, RenderContext, View,
|
||||
};
|
||||
|
||||
use super::{ConstrainedBox, Hook};
|
||||
|
|
|
@ -271,12 +271,10 @@ pub fn layout_highlighted_chunks<'a>(
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::{
|
||||
elements::Empty, fonts, ElementBox, Entity, MutableAppContext, RenderContext, View,
|
||||
};
|
||||
use crate::{elements::Empty, fonts, AppContext, ElementBox, Entity, RenderContext, View};
|
||||
|
||||
#[crate::test(self)]
|
||||
fn test_soft_wrapping_with_carriage_returns(cx: &mut MutableAppContext) {
|
||||
fn test_soft_wrapping_with_carriage_returns(cx: &mut AppContext) {
|
||||
let (window_id, _) = cx.add_window(Default::default(), |_| TestView);
|
||||
let mut presenter = cx.build_presenter(window_id, Default::default(), Default::default());
|
||||
fonts::with_font_cache(cx.font_cache().clone(), || {
|
||||
|
|
|
@ -5,9 +5,10 @@ use crate::{
|
|||
vector::{vec2f, Vector2F},
|
||||
},
|
||||
json::{self, json},
|
||||
platform::ScrollWheelEvent,
|
||||
presenter::MeasurementContext,
|
||||
scene::MouseScrollWheel,
|
||||
ElementBox, MouseRegion, RenderContext, ScrollWheelEvent, View,
|
||||
ElementBox, MouseRegion, RenderContext, View,
|
||||
};
|
||||
use json::ToJson;
|
||||
use std::{cell::RefCell, cmp, ops::Range, rc::Rc};
|
||||
|
|
|
@ -17,7 +17,7 @@ use std::{
|
|||
|
||||
use crate::{
|
||||
platform::{self, Dispatcher},
|
||||
util, MutableAppContext,
|
||||
util, AppContext,
|
||||
};
|
||||
|
||||
pub enum Foreground {
|
||||
|
@ -941,7 +941,7 @@ impl<T> Task<T> {
|
|||
}
|
||||
|
||||
impl<T: 'static, E: 'static + Display> Task<Result<T, E>> {
|
||||
pub fn detach_and_log_err(self, cx: &mut MutableAppContext) {
|
||||
pub fn detach_and_log_err(self, cx: &mut AppContext) {
|
||||
cx.spawn(|_| async move {
|
||||
if let Err(err) = self.await {
|
||||
log::error!("{}", err);
|
||||
|
|
|
@ -28,7 +28,6 @@ pub mod json;
|
|||
pub mod keymap_matcher;
|
||||
pub mod platform;
|
||||
pub use gpui_macros::test;
|
||||
pub use platform::*;
|
||||
pub use presenter::{
|
||||
Axis, DebugContext, EventContext, LayoutContext, MeasurementContext, PaintContext,
|
||||
SizeConstraint, Vector2FExt,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use std::ffi::CStr;
|
||||
|
||||
use crate::platform::Appearance;
|
||||
use cocoa::{
|
||||
appkit::{NSAppearanceNameVibrantDark, NSAppearanceNameVibrantLight},
|
||||
base::id,
|
||||
|
@ -7,8 +8,6 @@ use cocoa::{
|
|||
};
|
||||
use objc::{msg_send, sel, sel_impl};
|
||||
|
||||
use crate::Appearance;
|
||||
|
||||
impl Appearance {
|
||||
pub unsafe fn from_native(appearance: id) -> Self {
|
||||
let name: id = msg_send![appearance, name];
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
use crate::{
|
||||
geometry::vector::vec2f,
|
||||
keymap_matcher::Keystroke,
|
||||
platform::{Event, NavigationDirection},
|
||||
KeyDownEvent, KeyUpEvent, Modifiers, ModifiersChangedEvent, MouseButton, MouseButtonEvent,
|
||||
MouseExitedEvent, MouseMovedEvent, ScrollDelta, ScrollWheelEvent, TouchPhase,
|
||||
platform::{
|
||||
Event, KeyDownEvent, KeyUpEvent, Modifiers, ModifiersChangedEvent, MouseButton,
|
||||
MouseButtonEvent, MouseExitedEvent, MouseMovedEvent, NavigationDirection, ScrollDelta,
|
||||
ScrollWheelEvent, TouchPhase,
|
||||
},
|
||||
};
|
||||
use cocoa::{
|
||||
appkit::{NSEvent, NSEventModifierFlags, NSEventPhase, NSEventType},
|
||||
|
|
|
@ -498,12 +498,12 @@ extern "C" {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::MutableAppContext;
|
||||
use crate::AppContext;
|
||||
use font_kit::properties::{Style, Weight};
|
||||
use platform::FontSystem as _;
|
||||
|
||||
#[crate::test(self, retries = 5)]
|
||||
fn test_layout_str(_: &mut MutableAppContext) {
|
||||
fn test_layout_str(_: &mut AppContext) {
|
||||
// This is failing intermittently on CI and we don't have time to figure it out
|
||||
let fonts = FontSystem::new();
|
||||
let menlo = fonts.load_family("Menlo", &Default::default()).unwrap();
|
||||
|
|
|
@ -2,9 +2,9 @@ use super::atlas::{AllocId, AtlasAllocator};
|
|||
use crate::{
|
||||
fonts::{FontId, GlyphId},
|
||||
geometry::{rect::RectI, vector::Vector2I},
|
||||
platform::RasterizationOptions,
|
||||
platform::{FontSystem, RasterizationOptions},
|
||||
scene::ImageGlyph,
|
||||
FontSystem, ImageData,
|
||||
ImageData,
|
||||
};
|
||||
use anyhow::anyhow;
|
||||
use metal::{MTLPixelFormat, TextureDescriptor, TextureRef};
|
||||
|
|
|
@ -5,8 +5,8 @@ use super::{
|
|||
use crate::{
|
||||
executor,
|
||||
keymap_matcher::KeymapMatcher,
|
||||
platform::{self, CursorStyle},
|
||||
Action, AppVersion, ClipboardItem, Event, Menu, MenuItem,
|
||||
platform::{self, AppVersion, CursorStyle, Event},
|
||||
Action, ClipboardItem, Menu, MenuItem,
|
||||
};
|
||||
use anyhow::{anyhow, Result};
|
||||
use block::ConcreteBlock;
|
||||
|
@ -150,7 +150,7 @@ pub struct MacForegroundPlatformState {
|
|||
resign_active: Option<Box<dyn FnMut()>>,
|
||||
reopen: Option<Box<dyn FnMut()>>,
|
||||
quit: Option<Box<dyn FnMut()>>,
|
||||
event: Option<Box<dyn FnMut(crate::Event) -> bool>>,
|
||||
event: Option<Box<dyn FnMut(platform::Event) -> bool>>,
|
||||
menu_command: Option<Box<dyn FnMut(&dyn Action)>>,
|
||||
validate_menu_command: Option<Box<dyn FnMut(&dyn Action) -> bool>>,
|
||||
will_open_menu: Option<Box<dyn FnMut()>>,
|
||||
|
@ -342,7 +342,7 @@ impl platform::ForegroundPlatform for MacForegroundPlatform {
|
|||
self.0.borrow_mut().reopen = Some(callback);
|
||||
}
|
||||
|
||||
fn on_event(&self, callback: Box<dyn FnMut(crate::Event) -> bool>) {
|
||||
fn on_event(&self, callback: Box<dyn FnMut(platform::Event) -> bool>) {
|
||||
self.0.borrow_mut().event = Some(callback);
|
||||
}
|
||||
|
||||
|
@ -577,7 +577,7 @@ impl platform::Platform for MacPlatform {
|
|||
}
|
||||
}
|
||||
|
||||
fn screen_by_id(&self, id: uuid::Uuid) -> Option<Rc<dyn crate::Screen>> {
|
||||
fn screen_by_id(&self, id: uuid::Uuid) -> Option<Rc<dyn platform::Screen>> {
|
||||
Screen::find_by_id(id).map(|screen| Rc::new(screen) as Rc<_>)
|
||||
}
|
||||
|
||||
|
@ -864,7 +864,7 @@ impl platform::Platform for MacPlatform {
|
|||
"macOS"
|
||||
}
|
||||
|
||||
fn os_version(&self) -> Result<crate::AppVersion> {
|
||||
fn os_version(&self) -> Result<crate::platform::AppVersion> {
|
||||
unsafe {
|
||||
let process_info = NSProcessInfo::processInfo(nil);
|
||||
let version = process_info.operatingSystemVersion();
|
||||
|
|
|
@ -6,8 +6,9 @@ use crate::{
|
|||
platform::{
|
||||
self,
|
||||
mac::{platform::NSViewLayerContentsRedrawDuringViewResize, renderer::Renderer},
|
||||
Event, FontSystem, WindowBounds,
|
||||
},
|
||||
Event, FontSystem, Scene, WindowBounds,
|
||||
Scene,
|
||||
};
|
||||
use cocoa::{
|
||||
appkit::{NSScreen, NSSquareStatusItemLength, NSStatusBar, NSStatusItem, NSView, NSWindow},
|
||||
|
@ -185,15 +186,15 @@ impl platform::Window for StatusItem {
|
|||
0.
|
||||
}
|
||||
|
||||
fn appearance(&self) -> crate::Appearance {
|
||||
fn appearance(&self) -> platform::Appearance {
|
||||
unsafe {
|
||||
let appearance: id =
|
||||
msg_send![self.0.borrow().native_item.button(), effectiveAppearance];
|
||||
crate::Appearance::from_native(appearance)
|
||||
platform::Appearance::from_native(appearance)
|
||||
}
|
||||
}
|
||||
|
||||
fn screen(&self) -> Rc<dyn crate::Screen> {
|
||||
fn screen(&self) -> Rc<dyn platform::Screen> {
|
||||
unsafe {
|
||||
Rc::new(Screen {
|
||||
native_screen: self.0.borrow().native_window().screen(),
|
||||
|
@ -205,11 +206,11 @@ impl platform::Window for StatusItem {
|
|||
self
|
||||
}
|
||||
|
||||
fn set_input_handler(&mut self, _: Box<dyn crate::InputHandler>) {}
|
||||
fn set_input_handler(&mut self, _: Box<dyn platform::InputHandler>) {}
|
||||
|
||||
fn prompt(
|
||||
&self,
|
||||
_: crate::PromptLevel,
|
||||
_: crate::platform::PromptLevel,
|
||||
_: &str,
|
||||
_: &[&str],
|
||||
) -> postage::oneshot::Receiver<usize> {
|
||||
|
@ -251,7 +252,7 @@ impl platform::Window for StatusItem {
|
|||
unimplemented!()
|
||||
}
|
||||
|
||||
fn on_event(&mut self, callback: Box<dyn FnMut(crate::Event) -> bool>) {
|
||||
fn on_event(&mut self, callback: Box<dyn FnMut(platform::Event) -> bool>) {
|
||||
self.0.borrow_mut().event_callback = Some(callback);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,14 +5,14 @@ use crate::{
|
|||
vector::{vec2f, Vector2F},
|
||||
},
|
||||
keymap_matcher::Keystroke,
|
||||
mac::platform::NSViewLayerContentsRedrawDuringViewResize,
|
||||
platform::{
|
||||
self,
|
||||
mac::{renderer::Renderer, screen::Screen},
|
||||
Event, WindowBounds,
|
||||
mac::{
|
||||
platform::NSViewLayerContentsRedrawDuringViewResize, renderer::Renderer, screen::Screen,
|
||||
},
|
||||
Event, InputHandler, KeyDownEvent, ModifiersChangedEvent, MouseButton, MouseButtonEvent,
|
||||
MouseMovedEvent, Scene, WindowBounds, WindowKind,
|
||||
},
|
||||
InputHandler, KeyDownEvent, ModifiersChangedEvent, MouseButton, MouseButtonEvent,
|
||||
MouseMovedEvent, Scene, WindowKind,
|
||||
};
|
||||
use block::ConcreteBlock;
|
||||
use cocoa::{
|
||||
|
@ -670,14 +670,14 @@ impl platform::Window for Window {
|
|||
self.0.as_ref().borrow().titlebar_height()
|
||||
}
|
||||
|
||||
fn appearance(&self) -> crate::Appearance {
|
||||
fn appearance(&self) -> platform::Appearance {
|
||||
unsafe {
|
||||
let appearance: id = msg_send![self.0.borrow().native_window, effectiveAppearance];
|
||||
crate::Appearance::from_native(appearance)
|
||||
platform::Appearance::from_native(appearance)
|
||||
}
|
||||
}
|
||||
|
||||
fn screen(&self) -> Rc<dyn crate::Screen> {
|
||||
fn screen(&self) -> Rc<dyn platform::Screen> {
|
||||
unsafe {
|
||||
Rc::new(Screen {
|
||||
native_screen: self.0.as_ref().borrow().native_window.screen(),
|
||||
|
|
|
@ -64,7 +64,7 @@ impl super::ForegroundPlatform for ForegroundPlatform {
|
|||
fn on_resign_active(&self, _: Box<dyn FnMut()>) {}
|
||||
fn on_quit(&self, _: Box<dyn FnMut()>) {}
|
||||
fn on_reopen(&self, _: Box<dyn FnMut()>) {}
|
||||
fn on_event(&self, _: Box<dyn FnMut(crate::Event) -> bool>) {}
|
||||
fn on_event(&self, _: Box<dyn FnMut(crate::platform::Event) -> bool>) {}
|
||||
fn on_open_urls(&self, _: Box<dyn FnMut(Vec<String>)>) {}
|
||||
|
||||
fn run(&self, _on_finish_launching: Box<dyn FnOnce()>) {
|
||||
|
@ -134,11 +134,11 @@ impl super::Platform for Platform {
|
|||
|
||||
fn quit(&self) {}
|
||||
|
||||
fn screen_by_id(&self, _id: uuid::Uuid) -> Option<Rc<dyn crate::Screen>> {
|
||||
fn screen_by_id(&self, _id: uuid::Uuid) -> Option<Rc<dyn crate::platform::Screen>> {
|
||||
None
|
||||
}
|
||||
|
||||
fn screens(&self) -> Vec<Rc<dyn crate::Screen>> {
|
||||
fn screens(&self) -> Vec<Rc<dyn crate::platform::Screen>> {
|
||||
Default::default()
|
||||
}
|
||||
|
||||
|
@ -158,7 +158,7 @@ impl super::Platform for Platform {
|
|||
None
|
||||
}
|
||||
|
||||
fn add_status_item(&self) -> Box<dyn crate::Window> {
|
||||
fn add_status_item(&self) -> Box<dyn crate::platform::Window> {
|
||||
Box::new(Window::new(vec2f(24., 24.)))
|
||||
}
|
||||
|
||||
|
@ -301,11 +301,11 @@ impl super::Window for Window {
|
|||
24.
|
||||
}
|
||||
|
||||
fn appearance(&self) -> crate::Appearance {
|
||||
crate::Appearance::Light
|
||||
fn appearance(&self) -> crate::platform::Appearance {
|
||||
crate::platform::Appearance::Light
|
||||
}
|
||||
|
||||
fn screen(&self) -> Rc<dyn crate::Screen> {
|
||||
fn screen(&self) -> Rc<dyn crate::platform::Screen> {
|
||||
Rc::new(Screen)
|
||||
}
|
||||
|
||||
|
@ -313,9 +313,14 @@ impl super::Window for Window {
|
|||
self
|
||||
}
|
||||
|
||||
fn set_input_handler(&mut self, _: Box<dyn crate::InputHandler>) {}
|
||||
fn set_input_handler(&mut self, _: Box<dyn crate::platform::InputHandler>) {}
|
||||
|
||||
fn prompt(&self, _: crate::PromptLevel, _: &str, _: &[&str]) -> oneshot::Receiver<usize> {
|
||||
fn prompt(
|
||||
&self,
|
||||
_: crate::platform::PromptLevel,
|
||||
_: &str,
|
||||
_: &[&str],
|
||||
) -> oneshot::Receiver<usize> {
|
||||
let (done_tx, done_rx) = oneshot::channel();
|
||||
self.pending_prompts.borrow_mut().push_back(done_tx);
|
||||
done_rx
|
||||
|
@ -343,7 +348,7 @@ impl super::Window for Window {
|
|||
|
||||
fn toggle_full_screen(&self) {}
|
||||
|
||||
fn on_event(&mut self, callback: Box<dyn FnMut(crate::Event) -> bool>) {
|
||||
fn on_event(&mut self, callback: Box<dyn FnMut(crate::platform::Event) -> bool>) {
|
||||
self.event_handlers.push(callback);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +1,19 @@
|
|||
use crate::{
|
||||
app::{AppContext, MutableAppContext, WindowInvalidation},
|
||||
app::WindowInvalidation,
|
||||
elements::Element,
|
||||
font_cache::FontCache,
|
||||
geometry::rect::RectF,
|
||||
json::{self, ToJson},
|
||||
platform::{CursorStyle, Event},
|
||||
platform::{Appearance, CursorStyle, Event, FontSystem, MouseButton, MouseMovedEvent},
|
||||
scene::{
|
||||
CursorRegion, MouseClick, MouseDown, MouseDownOut, MouseDrag, MouseEvent, MouseHover,
|
||||
MouseMove, MouseMoveOut, MouseScrollWheel, MouseUp, MouseUpOut, Scene,
|
||||
},
|
||||
text_layout::TextLayoutCache,
|
||||
Action, AnyModelHandle, AnyViewHandle, AnyWeakModelHandle, AnyWeakViewHandle, Appearance,
|
||||
AssetCache, ElementBox, Entity, FontSystem, ModelHandle, MouseButton, MouseMovedEvent,
|
||||
MouseRegion, MouseRegionId, MouseState, ParentId, ReadModel, ReadView, RenderContext,
|
||||
RenderParams, SceneBuilder, UpgradeModelHandle, UpgradeViewHandle, View, ViewHandle,
|
||||
WeakModelHandle, WeakViewHandle,
|
||||
Action, AnyModelHandle, AnyViewHandle, AnyWeakModelHandle, AnyWeakViewHandle, AppContext,
|
||||
AssetCache, ElementBox, Entity, ModelHandle, MouseRegion, MouseRegionId, MouseState, ParentId,
|
||||
ReadModel, ReadView, RenderContext, RenderParams, SceneBuilder, UpgradeModelHandle,
|
||||
UpgradeViewHandle, View, ViewHandle, WeakModelHandle, WeakViewHandle,
|
||||
};
|
||||
use anyhow::bail;
|
||||
use collections::{HashMap, HashSet};
|
||||
|
@ -56,7 +55,7 @@ impl Presenter {
|
|||
font_cache: Arc<FontCache>,
|
||||
text_layout_cache: TextLayoutCache,
|
||||
asset_cache: Arc<AssetCache>,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) -> Self {
|
||||
Self {
|
||||
window_id,
|
||||
|
@ -80,7 +79,7 @@ impl Presenter {
|
|||
&mut self,
|
||||
invalidation: &mut WindowInvalidation,
|
||||
appearance: Appearance,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) {
|
||||
cx.start_frame();
|
||||
self.appearance = appearance;
|
||||
|
@ -111,7 +110,7 @@ impl Presenter {
|
|||
&mut self,
|
||||
invalidation: &mut WindowInvalidation,
|
||||
appearance: Appearance,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) {
|
||||
self.invalidate(invalidation, appearance, cx);
|
||||
for (view_id, view) in &mut self.rendered_views {
|
||||
|
@ -138,7 +137,7 @@ impl Presenter {
|
|||
window_size: Vector2F,
|
||||
scale_factor: f32,
|
||||
refreshing: bool,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) -> Scene {
|
||||
let mut scene_builder = SceneBuilder::new(scale_factor);
|
||||
|
||||
|
@ -169,7 +168,7 @@ impl Presenter {
|
|||
}
|
||||
}
|
||||
|
||||
fn layout(&mut self, window_size: Vector2F, refreshing: bool, cx: &mut MutableAppContext) {
|
||||
fn layout(&mut self, window_size: Vector2F, refreshing: bool, cx: &mut AppContext) {
|
||||
if let Some(root_view_id) = cx.root_view_id(self.window_id) {
|
||||
self.build_layout_context(window_size, refreshing, cx)
|
||||
.layout(root_view_id, SizeConstraint::strict(window_size));
|
||||
|
@ -180,7 +179,7 @@ impl Presenter {
|
|||
&'a mut self,
|
||||
window_size: Vector2F,
|
||||
refreshing: bool,
|
||||
cx: &'a mut MutableAppContext,
|
||||
cx: &'a mut AppContext,
|
||||
) -> LayoutContext<'a> {
|
||||
LayoutContext {
|
||||
window_id: self.window_id,
|
||||
|
@ -206,7 +205,7 @@ impl Presenter {
|
|||
&'a mut self,
|
||||
scene: &'a mut SceneBuilder,
|
||||
window_size: Vector2F,
|
||||
cx: &'a mut MutableAppContext,
|
||||
cx: &'a mut AppContext,
|
||||
) -> PaintContext {
|
||||
PaintContext {
|
||||
scene,
|
||||
|
@ -234,7 +233,7 @@ impl Presenter {
|
|||
&mut self,
|
||||
event: Event,
|
||||
event_reused: bool,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) -> bool {
|
||||
let mut mouse_events = SmallVec::<[_; 2]>::new();
|
||||
let mut notified_views: HashSet<usize> = Default::default();
|
||||
|
@ -557,7 +556,7 @@ impl Presenter {
|
|||
pub fn build_event_context<'a>(
|
||||
&'a mut self,
|
||||
notified_views: &'a mut HashSet<usize>,
|
||||
cx: &'a mut MutableAppContext,
|
||||
cx: &'a mut AppContext,
|
||||
) -> EventContext<'a> {
|
||||
EventContext {
|
||||
font_cache: &self.font_cache,
|
||||
|
@ -595,7 +594,7 @@ pub struct LayoutContext<'a> {
|
|||
pub font_system: Arc<dyn FontSystem>,
|
||||
pub text_layout_cache: &'a TextLayoutCache,
|
||||
pub asset_cache: &'a AssetCache,
|
||||
pub app: &'a mut MutableAppContext,
|
||||
pub app: &'a mut AppContext,
|
||||
pub refreshing: bool,
|
||||
pub window_size: Vector2F,
|
||||
titlebar_height: f32,
|
||||
|
@ -692,7 +691,7 @@ impl<'a> LayoutContext<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Deref for LayoutContext<'a> {
|
||||
type Target = MutableAppContext;
|
||||
type Target = AppContext;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
self.app
|
||||
|
@ -804,7 +803,7 @@ impl<'a> Deref for PaintContext<'a> {
|
|||
pub struct EventContext<'a> {
|
||||
pub font_cache: &'a FontCache,
|
||||
pub text_layout_cache: &'a TextLayoutCache,
|
||||
pub app: &'a mut MutableAppContext,
|
||||
pub app: &'a mut AppContext,
|
||||
pub window_id: usize,
|
||||
pub notify_count: usize,
|
||||
view_stack: Vec<usize>,
|
||||
|
@ -871,7 +870,7 @@ impl<'a> EventContext<'a> {
|
|||
}
|
||||
|
||||
impl<'a> Deref for EventContext<'a> {
|
||||
type Target = MutableAppContext;
|
||||
type Target = AppContext;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
self.app
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
use crate::{
|
||||
platform::{MouseButtonEvent, MouseMovedEvent, ScrollWheelEvent},
|
||||
scene::mouse_region::HandlerKey,
|
||||
};
|
||||
use pathfinder_geometry::{rect::RectF, vector::Vector2F};
|
||||
use std::{
|
||||
mem::{discriminant, Discriminant},
|
||||
ops::Deref,
|
||||
};
|
||||
|
||||
use pathfinder_geometry::{rect::RectF, vector::Vector2F};
|
||||
|
||||
use crate::{scene::mouse_region::HandlerKey, MouseButtonEvent, MouseMovedEvent, ScrollWheelEvent};
|
||||
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct MouseMove {
|
||||
pub region: RectF,
|
||||
|
|
|
@ -5,7 +5,7 @@ use collections::HashMap;
|
|||
use pathfinder_geometry::rect::RectF;
|
||||
use smallvec::SmallVec;
|
||||
|
||||
use crate::{EventContext, MouseButton};
|
||||
use crate::{platform::MouseButton, EventContext};
|
||||
|
||||
use super::{
|
||||
mouse_event::{
|
||||
|
@ -290,7 +290,7 @@ impl HandlerSet {
|
|||
handler(e, cx);
|
||||
} else {
|
||||
panic!(
|
||||
"Mouse Region Event incorrectly called with mismatched event type. Expected MouseRegionEvent::Move, found {:?}",
|
||||
"Mouse Region Event incorrectly called with mismatched event type. Expected MouseRegionEvent::Move, found {:?}",
|
||||
region_event);
|
||||
}
|
||||
}));
|
||||
|
@ -307,7 +307,7 @@ impl HandlerSet {
|
|||
handler(e, cx);
|
||||
} else {
|
||||
panic!(
|
||||
"Mouse Region Event incorrectly called with mismatched event type. Expected MouseRegionEvent::MoveOut, found {:?}",
|
||||
"Mouse Region Event incorrectly called with mismatched event type. Expected MouseRegionEvent::MoveOut, found {:?}",
|
||||
region_event);
|
||||
}
|
||||
}));
|
||||
|
@ -325,7 +325,7 @@ impl HandlerSet {
|
|||
handler(e, cx);
|
||||
} else {
|
||||
panic!(
|
||||
"Mouse Region Event incorrectly called with mismatched event type. Expected MouseRegionEvent::Down, found {:?}",
|
||||
"Mouse Region Event incorrectly called with mismatched event type. Expected MouseRegionEvent::Down, found {:?}",
|
||||
region_event);
|
||||
}
|
||||
}));
|
||||
|
@ -343,7 +343,7 @@ impl HandlerSet {
|
|||
handler(e, cx);
|
||||
} else {
|
||||
panic!(
|
||||
"Mouse Region Event incorrectly called with mismatched event type. Expected MouseRegionEvent::Up, found {:?}",
|
||||
"Mouse Region Event incorrectly called with mismatched event type. Expected MouseRegionEvent::Up, found {:?}",
|
||||
region_event);
|
||||
}
|
||||
}));
|
||||
|
@ -361,7 +361,7 @@ impl HandlerSet {
|
|||
handler(e, cx);
|
||||
} else {
|
||||
panic!(
|
||||
"Mouse Region Event incorrectly called with mismatched event type. Expected MouseRegionEvent::Click, found {:?}",
|
||||
"Mouse Region Event incorrectly called with mismatched event type. Expected MouseRegionEvent::Click, found {:?}",
|
||||
region_event);
|
||||
}
|
||||
}));
|
||||
|
@ -379,7 +379,7 @@ impl HandlerSet {
|
|||
handler(e, cx);
|
||||
} else {
|
||||
panic!(
|
||||
"Mouse Region Event incorrectly called with mismatched event type. Expected MouseRegionEvent::DownOut, found {:?}",
|
||||
"Mouse Region Event incorrectly called with mismatched event type. Expected MouseRegionEvent::DownOut, found {:?}",
|
||||
region_event);
|
||||
}
|
||||
}));
|
||||
|
@ -397,7 +397,7 @@ impl HandlerSet {
|
|||
handler(e, cx);
|
||||
} else {
|
||||
panic!(
|
||||
"Mouse Region Event incorrectly called with mismatched event type. Expected MouseRegionEvent::UpOut, found {:?}",
|
||||
"Mouse Region Event incorrectly called with mismatched event type. Expected MouseRegionEvent::UpOut, found {:?}",
|
||||
region_event);
|
||||
}
|
||||
}));
|
||||
|
@ -415,7 +415,7 @@ impl HandlerSet {
|
|||
handler(e, cx);
|
||||
} else {
|
||||
panic!(
|
||||
"Mouse Region Event incorrectly called with mismatched event type. Expected MouseRegionEvent::Drag, found {:?}",
|
||||
"Mouse Region Event incorrectly called with mismatched event type. Expected MouseRegionEvent::Drag, found {:?}",
|
||||
region_event);
|
||||
}
|
||||
}));
|
||||
|
@ -429,7 +429,7 @@ impl HandlerSet {
|
|||
handler(e, cx);
|
||||
} else {
|
||||
panic!(
|
||||
"Mouse Region Event incorrectly called with mismatched event type. Expected MouseRegionEvent::Hover, found {:?}",
|
||||
"Mouse Region Event incorrectly called with mismatched event type. Expected MouseRegionEvent::Hover, found {:?}",
|
||||
region_event);
|
||||
}
|
||||
}));
|
||||
|
|
|
@ -17,9 +17,10 @@ use crate::{
|
|||
elements::Empty,
|
||||
executor::{self, ExecutorEvent},
|
||||
platform,
|
||||
platform::Platform,
|
||||
util::CwdBacktrace,
|
||||
Element, ElementBox, Entity, FontCache, Handle, MutableAppContext, Platform, RenderContext,
|
||||
Subscription, TestAppContext, View,
|
||||
AppContext, Element, ElementBox, Entity, FontCache, Handle, RenderContext, Subscription,
|
||||
TestAppContext, View,
|
||||
};
|
||||
|
||||
#[cfg(test)]
|
||||
|
@ -40,7 +41,7 @@ pub fn run_test(
|
|||
detect_nondeterminism: bool,
|
||||
test_fn: &mut (dyn RefUnwindSafe
|
||||
+ Fn(
|
||||
&mut MutableAppContext,
|
||||
&mut AppContext,
|
||||
Rc<platform::test::ForegroundPlatform>,
|
||||
Arc<executor::Deterministic>,
|
||||
u64,
|
||||
|
|
|
@ -5,7 +5,9 @@ use crate::{
|
|||
rect::RectF,
|
||||
vector::{vec2f, Vector2F},
|
||||
},
|
||||
platform, scene, FontSystem, PaintContext,
|
||||
platform,
|
||||
platform::FontSystem,
|
||||
scene, PaintContext,
|
||||
};
|
||||
use ordered_float::OrderedFloat;
|
||||
use parking_lot::{Mutex, RwLock, RwLockUpgradableReadGuard};
|
||||
|
@ -660,7 +662,7 @@ mod tests {
|
|||
use crate::fonts::{Properties, Weight};
|
||||
|
||||
#[crate::test(self)]
|
||||
fn test_wrap_line(cx: &mut crate::MutableAppContext) {
|
||||
fn test_wrap_line(cx: &mut crate::AppContext) {
|
||||
let font_cache = cx.font_cache().clone();
|
||||
let font_system = cx.platform().fonts();
|
||||
let family = font_cache
|
||||
|
@ -721,7 +723,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[crate::test(self, retries = 5)]
|
||||
fn test_wrap_shaped_line(cx: &mut crate::MutableAppContext) {
|
||||
fn test_wrap_shaped_line(cx: &mut crate::AppContext) {
|
||||
// This is failing intermittently on CI and we don't have time to figure it out
|
||||
let font_cache = cx.font_cache().clone();
|
||||
let font_system = cx.platform().fonts();
|
||||
|
|
|
@ -2,6 +2,6 @@ mod select;
|
|||
|
||||
pub use select::{ItemType, Select, SelectStyle};
|
||||
|
||||
pub fn init(cx: &mut super::MutableAppContext) {
|
||||
pub fn init(cx: &mut super::AppContext) {
|
||||
select::init(cx);
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
use serde::Deserialize;
|
||||
|
||||
use crate::{
|
||||
actions, elements::*, impl_actions, AppContext, Entity, MouseButton, MutableAppContext,
|
||||
RenderContext, View, ViewContext, WeakViewHandle,
|
||||
actions, elements::*, impl_actions, platform::MouseButton, AppContext, Entity, RenderContext,
|
||||
View, ViewContext, WeakViewHandle,
|
||||
};
|
||||
|
||||
pub struct Select {
|
||||
|
@ -12,7 +12,7 @@ pub struct Select {
|
|||
item_count: usize,
|
||||
is_open: bool,
|
||||
list_state: UniformListState,
|
||||
build_style: Option<Box<dyn FnMut(&mut MutableAppContext) -> SelectStyle>>,
|
||||
build_style: Option<Box<dyn FnMut(&mut AppContext) -> SelectStyle>>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
|
@ -35,7 +35,7 @@ impl_actions!(select, [SelectItem]);
|
|||
|
||||
pub enum Event {}
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(Select::toggle);
|
||||
cx.add_action(Select::select_item);
|
||||
}
|
||||
|
@ -57,10 +57,7 @@ impl Select {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn with_style(
|
||||
mut self,
|
||||
f: impl 'static + FnMut(&mut MutableAppContext) -> SelectStyle,
|
||||
) -> Self {
|
||||
pub fn with_style(mut self, f: impl 'static + FnMut(&mut AppContext) -> SelectStyle) -> Self {
|
||||
self.build_style = Some(Box::new(f));
|
||||
self
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
use chrono::{Datelike, Local, NaiveTime, Timelike};
|
||||
use editor::{scroll::autoscroll::Autoscroll, Editor};
|
||||
use gpui::{actions, MutableAppContext};
|
||||
use gpui::{actions, AppContext};
|
||||
use settings::{HourFormat, Settings};
|
||||
use std::{
|
||||
fs::OpenOptions,
|
||||
|
@ -12,11 +12,11 @@ use workspace::AppState;
|
|||
|
||||
actions!(journal, [NewJournalEntry]);
|
||||
|
||||
pub fn init(app_state: Arc<AppState>, cx: &mut MutableAppContext) {
|
||||
pub fn init(app_state: Arc<AppState>, cx: &mut AppContext) {
|
||||
cx.add_global_action(move |_: &NewJournalEntry, cx| new_journal_entry(app_state.clone(), cx));
|
||||
}
|
||||
|
||||
pub fn new_journal_entry(app_state: Arc<AppState>, cx: &mut MutableAppContext) {
|
||||
pub fn new_journal_entry(app_state: Arc<AppState>, cx: &mut AppContext) {
|
||||
let settings = cx.global::<Settings>();
|
||||
let journal_dir = match journal_dir(&settings) {
|
||||
Some(journal_dir) => journal_dir,
|
||||
|
|
|
@ -15,7 +15,7 @@ use anyhow::{anyhow, Result};
|
|||
use clock::ReplicaId;
|
||||
use fs::LineEnding;
|
||||
use futures::FutureExt as _;
|
||||
use gpui::{fonts::HighlightStyle, AppContext, Entity, ModelContext, MutableAppContext, Task};
|
||||
use gpui::{fonts::HighlightStyle, AppContext, Entity, ModelContext, Task};
|
||||
use parking_lot::Mutex;
|
||||
use settings::Settings;
|
||||
use similar::{ChangeTag, TextDiff};
|
||||
|
@ -232,7 +232,7 @@ pub trait LocalFile: File {
|
|||
fingerprint: RopeFingerprint,
|
||||
line_ending: LineEnding,
|
||||
mtime: SystemTime,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ use super::*;
|
|||
use clock::ReplicaId;
|
||||
use collections::BTreeMap;
|
||||
use fs::LineEnding;
|
||||
use gpui::{ModelHandle, MutableAppContext};
|
||||
use gpui::{AppContext, ModelHandle};
|
||||
use indoc::indoc;
|
||||
use proto::deserialize_operation;
|
||||
use rand::prelude::*;
|
||||
|
@ -35,7 +35,7 @@ fn init_logger() {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_line_endings(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_line_endings(cx: &mut gpui::AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
cx.add_model(|cx| {
|
||||
let mut buffer =
|
||||
|
@ -128,7 +128,7 @@ fn test_select_language() {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_edit_events(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_edit_events(cx: &mut gpui::AppContext) {
|
||||
let mut now = Instant::now();
|
||||
let buffer_1_events = Rc::new(RefCell::new(Vec::new()));
|
||||
let buffer_2_events = Rc::new(RefCell::new(Vec::new()));
|
||||
|
@ -675,7 +675,7 @@ async fn test_symbols_containing(cx: &mut gpui::TestAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_enclosing_bracket_ranges(cx: &mut MutableAppContext) {
|
||||
fn test_enclosing_bracket_ranges(cx: &mut AppContext) {
|
||||
let mut assert = |selection_text, range_markers| {
|
||||
assert_bracket_pairs(selection_text, range_markers, rust_lang(), cx)
|
||||
};
|
||||
|
@ -791,9 +791,7 @@ fn test_enclosing_bracket_ranges(cx: &mut MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_enclosing_bracket_ranges_where_brackets_are_not_outermost_children(
|
||||
cx: &mut MutableAppContext,
|
||||
) {
|
||||
fn test_enclosing_bracket_ranges_where_brackets_are_not_outermost_children(cx: &mut AppContext) {
|
||||
let mut assert = |selection_text, bracket_pair_texts| {
|
||||
assert_bracket_pairs(selection_text, bracket_pair_texts, javascript_lang(), cx)
|
||||
};
|
||||
|
@ -825,7 +823,7 @@ fn test_enclosing_bracket_ranges_where_brackets_are_not_outermost_children(
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_range_for_syntax_ancestor(cx: &mut MutableAppContext) {
|
||||
fn test_range_for_syntax_ancestor(cx: &mut AppContext) {
|
||||
cx.add_model(|cx| {
|
||||
let text = "fn a() { b(|c| {}) }";
|
||||
let buffer = Buffer::new(0, text, cx).with_language(Arc::new(rust_lang()), cx);
|
||||
|
@ -863,7 +861,7 @@ fn test_range_for_syntax_ancestor(cx: &mut MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_autoindent_with_soft_tabs(cx: &mut MutableAppContext) {
|
||||
fn test_autoindent_with_soft_tabs(cx: &mut AppContext) {
|
||||
let settings = Settings::test(cx);
|
||||
cx.set_global(settings);
|
||||
|
||||
|
@ -904,7 +902,7 @@ fn test_autoindent_with_soft_tabs(cx: &mut MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_autoindent_with_hard_tabs(cx: &mut MutableAppContext) {
|
||||
fn test_autoindent_with_hard_tabs(cx: &mut AppContext) {
|
||||
let mut settings = Settings::test(cx);
|
||||
settings.editor_overrides.hard_tabs = Some(true);
|
||||
cx.set_global(settings);
|
||||
|
@ -946,7 +944,7 @@ fn test_autoindent_with_hard_tabs(cx: &mut MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_autoindent_does_not_adjust_lines_with_unchanged_suggestion(cx: &mut MutableAppContext) {
|
||||
fn test_autoindent_does_not_adjust_lines_with_unchanged_suggestion(cx: &mut AppContext) {
|
||||
let settings = Settings::test(cx);
|
||||
cx.set_global(settings);
|
||||
|
||||
|
@ -1083,7 +1081,7 @@ fn test_autoindent_does_not_adjust_lines_with_unchanged_suggestion(cx: &mut Muta
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_autoindent_does_not_adjust_lines_within_newly_created_errors(cx: &mut MutableAppContext) {
|
||||
fn test_autoindent_does_not_adjust_lines_within_newly_created_errors(cx: &mut AppContext) {
|
||||
let settings = Settings::test(cx);
|
||||
cx.set_global(settings);
|
||||
|
||||
|
@ -1146,7 +1144,7 @@ fn test_autoindent_does_not_adjust_lines_within_newly_created_errors(cx: &mut Mu
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_autoindent_adjusts_lines_when_only_text_changes(cx: &mut MutableAppContext) {
|
||||
fn test_autoindent_adjusts_lines_when_only_text_changes(cx: &mut AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
cx.add_model(|cx| {
|
||||
let mut buffer = Buffer::new(
|
||||
|
@ -1202,7 +1200,7 @@ fn test_autoindent_adjusts_lines_when_only_text_changes(cx: &mut MutableAppConte
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_autoindent_with_edit_at_end_of_buffer(cx: &mut MutableAppContext) {
|
||||
fn test_autoindent_with_edit_at_end_of_buffer(cx: &mut AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
cx.add_model(|cx| {
|
||||
let text = "a\nb";
|
||||
|
@ -1218,7 +1216,7 @@ fn test_autoindent_with_edit_at_end_of_buffer(cx: &mut MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_autoindent_multi_line_insertion(cx: &mut MutableAppContext) {
|
||||
fn test_autoindent_multi_line_insertion(cx: &mut AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
cx.add_model(|cx| {
|
||||
let text = "
|
||||
|
@ -1258,7 +1256,7 @@ fn test_autoindent_multi_line_insertion(cx: &mut MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_autoindent_block_mode(cx: &mut MutableAppContext) {
|
||||
fn test_autoindent_block_mode(cx: &mut AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
cx.add_model(|cx| {
|
||||
let text = r#"
|
||||
|
@ -1340,7 +1338,7 @@ fn test_autoindent_block_mode(cx: &mut MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_autoindent_block_mode_without_original_indent_columns(cx: &mut MutableAppContext) {
|
||||
fn test_autoindent_block_mode_without_original_indent_columns(cx: &mut AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
cx.add_model(|cx| {
|
||||
let text = r#"
|
||||
|
@ -1418,7 +1416,7 @@ fn test_autoindent_block_mode_without_original_indent_columns(cx: &mut MutableAp
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_autoindent_language_without_indents_query(cx: &mut MutableAppContext) {
|
||||
fn test_autoindent_language_without_indents_query(cx: &mut AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
cx.add_model(|cx| {
|
||||
let text = "
|
||||
|
@ -1461,7 +1459,7 @@ fn test_autoindent_language_without_indents_query(cx: &mut MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_autoindent_with_injected_languages(cx: &mut MutableAppContext) {
|
||||
fn test_autoindent_with_injected_languages(cx: &mut AppContext) {
|
||||
cx.set_global({
|
||||
let mut settings = Settings::test(cx);
|
||||
settings.language_overrides.extend([
|
||||
|
@ -1575,7 +1573,7 @@ fn test_autoindent_with_injected_languages(cx: &mut MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_autoindent_query_with_outdent_captures(cx: &mut MutableAppContext) {
|
||||
fn test_autoindent_query_with_outdent_captures(cx: &mut AppContext) {
|
||||
let mut settings = Settings::test(cx);
|
||||
settings.editor_defaults.tab_size = Some(2.try_into().unwrap());
|
||||
cx.set_global(settings);
|
||||
|
@ -1618,7 +1616,7 @@ fn test_autoindent_query_with_outdent_captures(cx: &mut MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_language_config_at(cx: &mut MutableAppContext) {
|
||||
fn test_language_config_at(cx: &mut AppContext) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
cx.add_model(|cx| {
|
||||
let language = Language::new(
|
||||
|
@ -1705,7 +1703,7 @@ fn test_language_config_at(cx: &mut MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test]
|
||||
fn test_serialization(cx: &mut gpui::MutableAppContext) {
|
||||
fn test_serialization(cx: &mut gpui::AppContext) {
|
||||
let mut now = Instant::now();
|
||||
|
||||
let buffer1 = cx.add_model(|cx| {
|
||||
|
@ -1746,7 +1744,7 @@ fn test_serialization(cx: &mut gpui::MutableAppContext) {
|
|||
}
|
||||
|
||||
#[gpui::test(iterations = 100)]
|
||||
fn test_random_collaboration(cx: &mut MutableAppContext, mut rng: StdRng) {
|
||||
fn test_random_collaboration(cx: &mut AppContext, mut rng: StdRng) {
|
||||
let min_peers = env::var("MIN_PEERS")
|
||||
.map(|i| i.parse().expect("invalid `MIN_PEERS` variable"))
|
||||
.unwrap_or(1);
|
||||
|
@ -2199,7 +2197,7 @@ fn assert_bracket_pairs(
|
|||
selection_text: &'static str,
|
||||
bracket_pair_texts: Vec<&'static str>,
|
||||
language: Language,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) {
|
||||
cx.set_global(Settings::test(cx));
|
||||
let (expected_text, selection_ranges) = marked_text_ranges(selection_text, false);
|
||||
|
|
|
@ -16,7 +16,7 @@ use futures::{
|
|||
future::{BoxFuture, Shared},
|
||||
FutureExt, TryFutureExt as _,
|
||||
};
|
||||
use gpui::{executor::Background, MutableAppContext, Task};
|
||||
use gpui::{executor::Background, AppContext, Task};
|
||||
use highlight_map::HighlightMap;
|
||||
use lazy_static::lazy_static;
|
||||
use lsp::CodeActionKind;
|
||||
|
@ -147,7 +147,7 @@ impl CachedLspAdapter {
|
|||
|
||||
pub fn workspace_configuration(
|
||||
&self,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) -> Option<BoxFuture<'static, Value>> {
|
||||
self.adapter.workspace_configuration(cx)
|
||||
}
|
||||
|
@ -223,10 +223,7 @@ pub trait LspAdapter: 'static + Send + Sync {
|
|||
None
|
||||
}
|
||||
|
||||
fn workspace_configuration(
|
||||
&self,
|
||||
_: &mut MutableAppContext,
|
||||
) -> Option<BoxFuture<'static, Value>> {
|
||||
fn workspace_configuration(&self, _: &mut AppContext) -> Option<BoxFuture<'static, Value>> {
|
||||
None
|
||||
}
|
||||
|
||||
|
@ -584,7 +581,7 @@ impl LanguageRegistry {
|
|||
result
|
||||
}
|
||||
|
||||
pub fn workspace_configuration(&self, cx: &mut MutableAppContext) -> Task<serde_json::Value> {
|
||||
pub fn workspace_configuration(&self, cx: &mut AppContext) -> Task<serde_json::Value> {
|
||||
let lsp_adapters = {
|
||||
let state = self.state.read();
|
||||
state
|
||||
|
@ -769,7 +766,7 @@ impl LanguageRegistry {
|
|||
language: Arc<Language>,
|
||||
root_path: Arc<Path>,
|
||||
http_client: Arc<dyn HttpClient>,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) -> Option<Task<Result<lsp::LanguageServer>>> {
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
if language.fake_adapter.is_some() {
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
use editor::Editor;
|
||||
use gpui::{
|
||||
elements::*, CursorStyle, Entity, MouseButton, RenderContext, Subscription, View, ViewContext,
|
||||
ViewHandle,
|
||||
elements::*,
|
||||
platform::{CursorStyle, MouseButton},
|
||||
Entity, RenderContext, Subscription, View, ViewContext, ViewHandle,
|
||||
};
|
||||
use settings::Settings;
|
||||
use std::sync::Arc;
|
||||
|
|
|
@ -5,7 +5,7 @@ use editor::Editor;
|
|||
use fuzzy::{match_strings, StringMatch, StringMatchCandidate};
|
||||
use gpui::{
|
||||
actions, elements::*, AnyViewHandle, AppContext, Entity, ModelHandle, MouseState,
|
||||
MutableAppContext, RenderContext, View, ViewContext, ViewHandle,
|
||||
RenderContext, View, ViewContext, ViewHandle,
|
||||
};
|
||||
use language::{Buffer, LanguageRegistry};
|
||||
use picker::{Picker, PickerDelegate};
|
||||
|
@ -16,7 +16,7 @@ use workspace::{AppState, Workspace};
|
|||
|
||||
actions!(language_selector, [Toggle]);
|
||||
|
||||
pub fn init(app_state: Arc<AppState>, cx: &mut MutableAppContext) {
|
||||
pub fn init(app_state: Arc<AppState>, cx: &mut AppContext) {
|
||||
Picker::<LanguageSelector>::init(cx);
|
||||
cx.add_action({
|
||||
let language_registry = app_state.languages.clone();
|
||||
|
|
|
@ -89,6 +89,6 @@ fn main() {
|
|||
});
|
||||
}
|
||||
|
||||
fn quit(_: &Quit, cx: &mut gpui::MutableAppContext) {
|
||||
fn quit(_: &Quit, cx: &mut gpui::AppContext) {
|
||||
cx.platform().quit();
|
||||
}
|
||||
|
|
|
@ -5,7 +5,7 @@ use editor::{
|
|||
use fuzzy::StringMatch;
|
||||
use gpui::{
|
||||
actions, elements::*, geometry::vector::Vector2F, AnyViewHandle, AppContext, Entity,
|
||||
MouseState, MutableAppContext, RenderContext, Task, View, ViewContext, ViewHandle,
|
||||
MouseState, RenderContext, Task, View, ViewContext, ViewHandle,
|
||||
};
|
||||
use language::Outline;
|
||||
use ordered_float::OrderedFloat;
|
||||
|
@ -16,7 +16,7 @@ use workspace::Workspace;
|
|||
|
||||
actions!(outline, [Toggle]);
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(OutlineView::toggle);
|
||||
Picker::<OutlineView>::init(cx);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ pub enum Event {
|
|||
impl Entity for OutlineView {
|
||||
type Event = Event;
|
||||
|
||||
fn release(&mut self, cx: &mut MutableAppContext) {
|
||||
fn release(&mut self, cx: &mut AppContext) {
|
||||
self.restore_active_editor(cx);
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ impl OutlineView {
|
|||
}
|
||||
}
|
||||
|
||||
fn restore_active_editor(&mut self, cx: &mut MutableAppContext) {
|
||||
fn restore_active_editor(&mut self, cx: &mut AppContext) {
|
||||
self.active_editor.update(cx, |editor, cx| {
|
||||
editor.highlight_rows(None);
|
||||
if let Some(scroll_position) = self.prev_scroll_position {
|
||||
|
|
|
@ -3,9 +3,9 @@ use gpui::{
|
|||
elements::*,
|
||||
geometry::vector::{vec2f, Vector2F},
|
||||
keymap_matcher::KeymapContext,
|
||||
platform::CursorStyle,
|
||||
AnyViewHandle, AppContext, Axis, Entity, MouseButton, MouseState, MutableAppContext,
|
||||
RenderContext, Task, View, ViewContext, ViewHandle, WeakViewHandle,
|
||||
platform::{CursorStyle, MouseButton},
|
||||
AnyViewHandle, AppContext, Axis, Entity, MouseState, RenderContext, Task, View, ViewContext,
|
||||
ViewHandle, WeakViewHandle,
|
||||
};
|
||||
use menu::{Cancel, Confirm, SelectFirst, SelectIndex, SelectLast, SelectNext, SelectPrev};
|
||||
use parking_lot::Mutex;
|
||||
|
@ -141,7 +141,7 @@ impl<D: PickerDelegate> View for Picker<D> {
|
|||
}
|
||||
|
||||
impl<D: PickerDelegate> Picker<D> {
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(Self::select_first);
|
||||
cx.add_action(Self::select_last);
|
||||
cx.add_action(Self::select_next);
|
||||
|
|
|
@ -4,7 +4,7 @@ use crate::{
|
|||
use anyhow::{anyhow, Result};
|
||||
use async_trait::async_trait;
|
||||
use client::proto::{self, PeerId};
|
||||
use gpui::{AppContext, AsyncAppContext, ModelHandle, MutableAppContext};
|
||||
use gpui::{AppContext, AsyncAppContext, ModelHandle};
|
||||
use language::{
|
||||
point_from_lsp, point_to_lsp,
|
||||
proto::{deserialize_anchor, deserialize_version, serialize_anchor, serialize_version},
|
||||
|
@ -49,7 +49,7 @@ pub(crate) trait LspCommand: 'static + Sized {
|
|||
project: &mut Project,
|
||||
peer_id: PeerId,
|
||||
buffer_version: &clock::Global,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) -> <Self::ProtoRequest as proto::RequestMessage>::Response;
|
||||
async fn response_from_proto(
|
||||
self,
|
||||
|
@ -175,7 +175,7 @@ impl LspCommand for PrepareRename {
|
|||
_: &mut Project,
|
||||
_: PeerId,
|
||||
buffer_version: &clock::Global,
|
||||
_: &mut MutableAppContext,
|
||||
_: &mut AppContext,
|
||||
) -> proto::PrepareRenameResponse {
|
||||
proto::PrepareRenameResponse {
|
||||
can_rename: range.is_some(),
|
||||
|
@ -296,7 +296,7 @@ impl LspCommand for PerformRename {
|
|||
project: &mut Project,
|
||||
peer_id: PeerId,
|
||||
_: &clock::Global,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) -> proto::PerformRenameResponse {
|
||||
let transaction = project.serialize_project_transaction_for_peer(response, peer_id, cx);
|
||||
proto::PerformRenameResponse {
|
||||
|
@ -391,7 +391,7 @@ impl LspCommand for GetDefinition {
|
|||
project: &mut Project,
|
||||
peer_id: PeerId,
|
||||
_: &clock::Global,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) -> proto::GetDefinitionResponse {
|
||||
let links = location_links_to_proto(response, project, peer_id, cx);
|
||||
proto::GetDefinitionResponse { links }
|
||||
|
@ -477,7 +477,7 @@ impl LspCommand for GetTypeDefinition {
|
|||
project: &mut Project,
|
||||
peer_id: PeerId,
|
||||
_: &clock::Global,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) -> proto::GetTypeDefinitionResponse {
|
||||
let links = location_links_to_proto(response, project, peer_id, cx);
|
||||
proto::GetTypeDefinitionResponse { links }
|
||||
|
@ -658,7 +658,7 @@ fn location_links_to_proto(
|
|||
links: Vec<LocationLink>,
|
||||
project: &mut Project,
|
||||
peer_id: PeerId,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) -> Vec<proto::LocationLink> {
|
||||
links
|
||||
.into_iter()
|
||||
|
@ -787,7 +787,7 @@ impl LspCommand for GetReferences {
|
|||
project: &mut Project,
|
||||
peer_id: PeerId,
|
||||
_: &clock::Global,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) -> proto::GetReferencesResponse {
|
||||
let locations = response
|
||||
.into_iter()
|
||||
|
@ -928,7 +928,7 @@ impl LspCommand for GetDocumentHighlights {
|
|||
_: &mut Project,
|
||||
_: PeerId,
|
||||
_: &clock::Global,
|
||||
_: &mut MutableAppContext,
|
||||
_: &mut AppContext,
|
||||
) -> proto::GetDocumentHighlightsResponse {
|
||||
let highlights = response
|
||||
.into_iter()
|
||||
|
@ -1130,7 +1130,7 @@ impl LspCommand for GetHover {
|
|||
_: &mut Project,
|
||||
_: PeerId,
|
||||
_: &clock::Global,
|
||||
_: &mut MutableAppContext,
|
||||
_: &mut AppContext,
|
||||
) -> proto::GetHoverResponse {
|
||||
if let Some(response) = response {
|
||||
let (start, end) = if let Some(range) = response.range {
|
||||
|
|
|
@ -21,8 +21,8 @@ use futures::{
|
|||
AsyncWriteExt, Future, FutureExt, StreamExt, TryFutureExt,
|
||||
};
|
||||
use gpui::{
|
||||
AnyModelHandle, AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle,
|
||||
MutableAppContext, Task, UpgradeModelHandle, WeakModelHandle,
|
||||
AnyModelHandle, AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, Task,
|
||||
UpgradeModelHandle, WeakModelHandle,
|
||||
};
|
||||
use language::{
|
||||
point_to_lsp,
|
||||
|
@ -427,7 +427,7 @@ impl Project {
|
|||
user_store: ModelHandle<UserStore>,
|
||||
languages: Arc<LanguageRegistry>,
|
||||
fs: Arc<dyn Fs>,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) -> ModelHandle<Self> {
|
||||
cx.add_model(|cx: &mut ModelContext<Self>| {
|
||||
let (tx, rx) = mpsc::unbounded();
|
||||
|
@ -5902,7 +5902,7 @@ impl Project {
|
|||
&mut self,
|
||||
project_transaction: ProjectTransaction,
|
||||
peer_id: proto::PeerId,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) -> proto::ProjectTransaction {
|
||||
let mut serialized_transaction = proto::ProjectTransaction {
|
||||
buffer_ids: Default::default(),
|
||||
|
@ -5960,7 +5960,7 @@ impl Project {
|
|||
&mut self,
|
||||
buffer: &ModelHandle<Buffer>,
|
||||
peer_id: proto::PeerId,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) -> u64 {
|
||||
let buffer_id = buffer.read(cx).remote_id();
|
||||
if let Some(project_id) = self.remote_id() {
|
||||
|
@ -6573,7 +6573,7 @@ impl<'a> Iterator for PathMatchCandidateSetIter<'a> {
|
|||
impl Entity for Project {
|
||||
type Event = Event;
|
||||
|
||||
fn release(&mut self, _: &mut gpui::MutableAppContext) {
|
||||
fn release(&mut self, _: &mut gpui::AppContext) {
|
||||
match &self.client_state {
|
||||
Some(ProjectClientState::Local { remote_id, .. }) => {
|
||||
let _ = self.client.send(proto::UnshareProject {
|
||||
|
@ -6591,7 +6591,7 @@ impl Entity for Project {
|
|||
|
||||
fn app_will_quit(
|
||||
&mut self,
|
||||
_: &mut MutableAppContext,
|
||||
_: &mut AppContext,
|
||||
) -> Option<std::pin::Pin<Box<dyn 'static + Future<Output = ()>>>> {
|
||||
let shutdown_futures = self
|
||||
.language_servers
|
||||
|
|
|
@ -2,6 +2,7 @@ use crate::{worktree::WorktreeHandle, Event, *};
|
|||
use fs::LineEnding;
|
||||
use fs::{FakeFs, RealFs};
|
||||
use futures::{future, StreamExt};
|
||||
use gpui::AppContext;
|
||||
use gpui::{executor::Deterministic, test::subscribe};
|
||||
use language::{
|
||||
tree_sitter_rust, tree_sitter_typescript, Diagnostic, FakeLspAdapter, LanguageConfig,
|
||||
|
|
|
@ -16,10 +16,7 @@ use futures::{
|
|||
};
|
||||
use fuzzy::CharBag;
|
||||
use git::{DOT_GIT, GITIGNORE};
|
||||
use gpui::{
|
||||
executor, AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, MutableAppContext,
|
||||
Task,
|
||||
};
|
||||
use gpui::{executor, AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, Task};
|
||||
use language::{
|
||||
proto::{
|
||||
deserialize_fingerprint, deserialize_version, serialize_fingerprint, serialize_line_ending,
|
||||
|
@ -287,7 +284,7 @@ impl Worktree {
|
|||
replica_id: ReplicaId,
|
||||
worktree: proto::WorktreeMetadata,
|
||||
client: Arc<Client>,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) -> ModelHandle<Self> {
|
||||
cx.add_model(|cx: &mut ModelContext<Self>| {
|
||||
let snapshot = Snapshot {
|
||||
|
@ -1895,7 +1892,7 @@ impl language::LocalFile for File {
|
|||
fingerprint: RopeFingerprint,
|
||||
line_ending: LineEnding,
|
||||
mtime: SystemTime,
|
||||
cx: &mut MutableAppContext,
|
||||
cx: &mut AppContext,
|
||||
) {
|
||||
let worktree = self.worktree.read(cx).as_local().unwrap();
|
||||
if let Some(project_id) = worktree.share.as_ref().map(|share| share.project_id) {
|
||||
|
|
|
@ -12,9 +12,9 @@ use gpui::{
|
|||
geometry::vector::Vector2F,
|
||||
impl_internal_actions,
|
||||
keymap_matcher::KeymapContext,
|
||||
platform::CursorStyle,
|
||||
AppContext, ClipboardItem, Element, ElementBox, Entity, ModelHandle, MouseButton,
|
||||
MutableAppContext, PromptLevel, RenderContext, Task, View, ViewContext, ViewHandle,
|
||||
platform::{CursorStyle, MouseButton, PromptLevel},
|
||||
AppContext, ClipboardItem, Element, ElementBox, Entity, ModelHandle, RenderContext, Task, View,
|
||||
ViewContext, ViewHandle,
|
||||
};
|
||||
use menu::{Confirm, SelectNext, SelectPrev};
|
||||
use project::{Entry, EntryKind, Project, ProjectEntryId, ProjectPath, Worktree, WorktreeId};
|
||||
|
@ -24,7 +24,7 @@ use std::{
|
|||
collections::{hash_map, HashMap},
|
||||
ffi::OsStr,
|
||||
ops::Range,
|
||||
path::{Path, PathBuf},
|
||||
path::Path,
|
||||
sync::Arc,
|
||||
};
|
||||
use theme::ProjectPanelEntry;
|
||||
|
@ -119,6 +119,7 @@ actions!(
|
|||
NewFile,
|
||||
Copy,
|
||||
CopyPath,
|
||||
CopyRelativePath,
|
||||
RevealInFinder,
|
||||
Cut,
|
||||
Paste,
|
||||
|
@ -132,7 +133,7 @@ impl_internal_actions!(
|
|||
[Open, ToggleExpanded, DeployContextMenu, MoveProjectEntry]
|
||||
);
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(ProjectPanel::deploy_context_menu);
|
||||
cx.add_action(ProjectPanel::expand_selected_entry);
|
||||
cx.add_action(ProjectPanel::collapse_selected_entry);
|
||||
|
@ -146,10 +147,11 @@ pub fn init(cx: &mut MutableAppContext) {
|
|||
cx.add_async_action(ProjectPanel::delete);
|
||||
cx.add_async_action(ProjectPanel::confirm);
|
||||
cx.add_action(ProjectPanel::cancel);
|
||||
cx.add_action(ProjectPanel::cut);
|
||||
cx.add_action(ProjectPanel::copy);
|
||||
cx.add_action(ProjectPanel::copy_path);
|
||||
cx.add_action(ProjectPanel::copy_relative_path);
|
||||
cx.add_action(ProjectPanel::reveal_in_finder);
|
||||
cx.add_action(ProjectPanel::cut);
|
||||
cx.add_action(
|
||||
|this: &mut ProjectPanel, action: &Paste, cx: &mut ViewContext<ProjectPanel>| {
|
||||
this.paste(action, cx);
|
||||
|
@ -307,11 +309,16 @@ impl ProjectPanel {
|
|||
}
|
||||
menu_entries.push(ContextMenuItem::item("New File", NewFile));
|
||||
menu_entries.push(ContextMenuItem::item("New Folder", NewDirectory));
|
||||
menu_entries.push(ContextMenuItem::item("Reveal in Finder", RevealInFinder));
|
||||
menu_entries.push(ContextMenuItem::Separator);
|
||||
menu_entries.push(ContextMenuItem::item("Copy", Copy));
|
||||
menu_entries.push(ContextMenuItem::item("Copy Path", CopyPath));
|
||||
menu_entries.push(ContextMenuItem::item("Cut", Cut));
|
||||
menu_entries.push(ContextMenuItem::item("Copy", Copy));
|
||||
menu_entries.push(ContextMenuItem::Separator);
|
||||
menu_entries.push(ContextMenuItem::item("Copy Path", CopyPath));
|
||||
menu_entries.push(ContextMenuItem::item(
|
||||
"Copy Relative Path",
|
||||
CopyRelativePath,
|
||||
));
|
||||
menu_entries.push(ContextMenuItem::item("Reveal in Finder", RevealInFinder));
|
||||
if let Some(clipboard_entry) = self.clipboard_entry {
|
||||
if clipboard_entry.worktree_id() == worktree.id() {
|
||||
menu_entries.push(ContextMenuItem::item("Paste", Paste));
|
||||
|
@ -785,10 +792,19 @@ impl ProjectPanel {
|
|||
|
||||
fn copy_path(&mut self, _: &CopyPath, cx: &mut ViewContext<Self>) {
|
||||
if let Some((worktree, entry)) = self.selected_entry(cx) {
|
||||
let mut path = PathBuf::new();
|
||||
path.push(worktree.root_name());
|
||||
path.push(&entry.path);
|
||||
cx.write_to_clipboard(ClipboardItem::new(path.to_string_lossy().to_string()));
|
||||
cx.write_to_clipboard(ClipboardItem::new(
|
||||
worktree
|
||||
.abs_path()
|
||||
.join(&entry.path)
|
||||
.to_string_lossy()
|
||||
.to_string(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
fn copy_relative_path(&mut self, _: &CopyRelativePath, cx: &mut ViewContext<Self>) {
|
||||
if let Some((_, entry)) = self.selected_entry(cx) {
|
||||
cx.write_to_clipboard(ClipboardItem::new(entry.path.to_string_lossy().to_string()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ use editor::{
|
|||
use fuzzy::{StringMatch, StringMatchCandidate};
|
||||
use gpui::{
|
||||
actions, elements::*, AnyViewHandle, AppContext, Entity, ModelHandle, MouseState,
|
||||
MutableAppContext, RenderContext, Task, View, ViewContext, ViewHandle,
|
||||
RenderContext, Task, View, ViewContext, ViewHandle,
|
||||
};
|
||||
use ordered_float::OrderedFloat;
|
||||
use picker::{Picker, PickerDelegate};
|
||||
|
@ -17,7 +17,7 @@ use workspace::Workspace;
|
|||
|
||||
actions!(project_symbols, [Toggle]);
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(ProjectSymbolsView::toggle);
|
||||
Picker::<ProjectSymbolsView>::init(cx);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ use fuzzy::{StringMatch, StringMatchCandidate};
|
|||
use gpui::{
|
||||
actions,
|
||||
elements::{ChildView, Flex, ParentElement},
|
||||
AnyViewHandle, Element, ElementBox, Entity, MutableAppContext, RenderContext, Task, View,
|
||||
ViewContext, ViewHandle,
|
||||
AnyViewHandle, AppContext, Element, ElementBox, Entity, RenderContext, Task, View, ViewContext,
|
||||
ViewHandle,
|
||||
};
|
||||
use highlighted_workspace_location::HighlightedWorkspaceLocation;
|
||||
use ordered_float::OrderedFloat;
|
||||
|
@ -18,7 +18,7 @@ use workspace::{
|
|||
|
||||
actions!(projects, [OpenRecent]);
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(RecentProjectsView::toggle);
|
||||
Picker::<RecentProjectsView>::init(cx);
|
||||
}
|
||||
|
|
|
@ -5,9 +5,12 @@ use crate::{
|
|||
use collections::HashMap;
|
||||
use editor::Editor;
|
||||
use gpui::{
|
||||
actions, elements::*, impl_actions, platform::CursorStyle, Action, AnyViewHandle, AppContext,
|
||||
Entity, MouseButton, MutableAppContext, RenderContext, Subscription, Task, View, ViewContext,
|
||||
ViewHandle,
|
||||
actions,
|
||||
elements::*,
|
||||
impl_actions,
|
||||
platform::{CursorStyle, MouseButton},
|
||||
Action, AnyViewHandle, AppContext, Entity, RenderContext, Subscription, Task, View,
|
||||
ViewContext, ViewHandle,
|
||||
};
|
||||
use project::search::SearchQuery;
|
||||
use serde::Deserialize;
|
||||
|
@ -31,7 +34,7 @@ pub enum Event {
|
|||
UpdateLocation,
|
||||
}
|
||||
|
||||
pub fn init(cx: &mut MutableAppContext) {
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
cx.add_action(BufferSearchBar::deploy);
|
||||
cx.add_action(BufferSearchBar::dismiss);
|
||||
cx.add_action(BufferSearchBar::focus_editor);
|
||||
|
@ -45,7 +48,7 @@ pub fn init(cx: &mut MutableAppContext) {
|
|||
add_toggle_option_action::<ToggleRegex>(SearchOption::Regex, cx);
|
||||
}
|
||||
|
||||
fn add_toggle_option_action<A: Action>(option: SearchOption, cx: &mut MutableAppContext) {
|
||||
fn add_toggle_option_action<A: Action>(option: SearchOption, cx: &mut AppContext) {
|
||||
cx.add_action(move |pane: &mut Pane, _: &A, cx: &mut ViewContext<Pane>| {
|
||||
if let Some(search_bar) = pane.toolbar().read(cx).item_of_type::<BufferSearchBar>() {
|
||||
if search_bar.update(cx, |search_bar, cx| search_bar.show(false, false, cx)) {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue