Merge MutableAppContext into AppContext

There may have been a good reason for the difference at some point, or I was
still learning Rust. But now it's just &mut AppContext vs &AppContext.
This commit is contained in:
Nathan Sobo 2023-04-06 15:49:03 -06:00
parent dd00966cc6
commit de9bf6dfbd
112 changed files with 882 additions and 1041 deletions

View File

@ -3,7 +3,7 @@ use editor::Editor;
use futures::StreamExt;
use gpui::{
actions, elements::*, platform::CursorStyle, Action, AppContext, Entity, ModelHandle,
MouseButton, MutableAppContext, RenderContext, View, ViewContext, ViewHandle,
MouseButton, RenderContext, View, ViewContext, ViewHandle,
};
use language::{LanguageRegistry, LanguageServerBinaryStatus};
use project::{LanguageServerProgress, Project};
@ -46,7 +46,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);
}

View File

@ -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()
}

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -11,7 +11,7 @@ use collections::{BTreeMap, HashMap, HashSet};
use fs::Fs;
use futures::{FutureExt, StreamExt};
use gpui::{
AsyncAppContext, Entity, ModelContext, ModelHandle, MutableAppContext, Task, WeakModelHandle,
AsyncAppContext, Entity, ModelContext, ModelHandle, AppContext, Task, WeakModelHandle,
};
use language::LanguageRegistry;
use live_kit_client::{LocalTrackPublication, LocalVideoTrack, RemoteVideoTrackUpdate};
@ -64,7 +64,7 @@ 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);
}
@ -72,7 +72,7 @@ impl Entity for Room {
fn app_will_quit(
&mut self,
cx: &mut MutableAppContext,
cx: &mut AppContext,
) -> Option<Pin<Box<dyn Future<Output = ()>>>> {
if self.status.is_online() {
let leave = self.leave_internal(cx);
@ -176,7 +176,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 +219,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 +257,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")));
}

View File

@ -15,7 +15,7 @@ use gpui::{
actions,
serde_json::{self, Value},
AnyModelHandle, AnyViewHandle, AnyWeakModelHandle, AnyWeakViewHandle, AppContext, AppVersion,
AsyncAppContext, Entity, ModelHandle, MutableAppContext, Task, View, ViewContext, ViewHandle,
AsyncAppContext, Entity, ModelHandle, Task, View, ViewContext, ViewHandle,
};
use lazy_static::lazy_static;
use parking_lot::RwLock;
@ -67,7 +67,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| {

View File

@ -15,7 +15,7 @@ use gpui::{
geometry::{rect::RectF, vector::vec2f, PathBuilder},
impl_internal_actions,
json::{self, ToJson},
CursorStyle, Entity, ImageData, ModelHandle, MouseButton, MutableAppContext, RenderContext,
AppContext, CursorStyle, Entity, ImageData, ModelHandle, MouseButton, RenderContext,
Subscription, View, ViewContext, ViewHandle, WeakViewHandle,
};
use settings::Settings;
@ -40,7 +40,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);

View File

@ -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)
})

View File

@ -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);
}

View File

@ -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,
AppContext, CursorStyle, Entity, ModelHandle, MouseButton, PromptLevel, 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);

View File

@ -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,
elements::*, impl_internal_actions, Entity, ModelHandle, AppContext, 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);
}

View File

@ -1,7 +1,7 @@
use crate::{contact_finder::ContactFinder, contact_list::ContactList, ToggleContactsMenu};
use client::UserStore;
use gpui::{
actions, elements::*, Entity, ModelHandle, MouseButton, MutableAppContext, RenderContext, View,
actions, elements::*, AppContext, Entity, ModelHandle, MouseButton, RenderContext, View,
ViewContext, ViewHandle,
};
use project::Project;
@ -9,7 +9,7 @@ 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);
}

View File

@ -4,7 +4,7 @@ use futures::StreamExt;
use gpui::{
elements::*,
geometry::{rect::RectF, vector::vec2f},
impl_internal_actions, CursorStyle, Entity, MouseButton, MutableAppContext, RenderContext,
impl_internal_actions, CursorStyle, Entity, MouseButton, AppContext, RenderContext,
View, ViewContext, WindowBounds, WindowKind, WindowOptions,
};
use settings::Settings;
@ -13,7 +13,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();

View File

@ -5,7 +5,7 @@ use gpui::{
actions,
elements::*,
geometry::{rect::RectF, vector::vec2f},
CursorStyle, Entity, MouseButton, MutableAppContext, RenderContext, View, ViewContext,
CursorStyle, Entity, MouseButton, AppContext, RenderContext, View, ViewContext,
WindowBounds, WindowKind, WindowOptions,
};
use settings::Settings;
@ -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);

View File

@ -2,13 +2,13 @@ use call::ActiveCall;
use gpui::{
color::Color,
elements::{MouseEventHandler, Svg},
Appearance, Element, ElementBox, Entity, MouseButton, MutableAppContext, RenderContext, View,
Appearance, Element, ElementBox, Entity, MouseButton, AppContext, 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;

View File

@ -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, Element, Entity, MouseState, AppContext, 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);
}

View File

@ -1,20 +1,20 @@
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,
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);

View File

@ -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| {

View File

@ -1,6 +1,6 @@
use crate::{request::PromptUserDeviceFlow, Copilot, Status};
use gpui::{
elements::*, geometry::rect::RectF, ClipboardItem, Element, Entity, MutableAppContext, View,
elements::*, geometry::rect::RectF, ClipboardItem, Element, Entity, AppContext, View,
ViewContext, ViewHandle, WindowKind, WindowOptions,
};
use settings::Settings;
@ -14,7 +14,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,7 +57,7 @@ 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>>,
) {

View File

@ -3,8 +3,8 @@ 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, AppContext, CursorStyle, Element, ElementBox, Entity,
MouseButton, MouseState, RenderContext, Subscription, View, ViewContext, ViewHandle,
};
use settings::{settings_file::SettingsFile, Settings};
use workspace::{
@ -43,7 +43,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| {

View File

@ -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,
{

View File

@ -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| {

View File

@ -2,7 +2,7 @@ use collections::HashSet;
use editor::{Editor, GoToDiagnostic};
use gpui::{
elements::*, platform::CursorStyle, serde_json, Entity, ModelHandle, MouseButton,
MutableAppContext, RenderContext, Subscription, View, ViewContext, ViewHandle, WeakViewHandle,
AppContext, RenderContext, Subscription, View, ViewContext, ViewHandle, WeakViewHandle,
};
use language::Diagnostic;
use project::Project;
@ -17,7 +17,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);
}

View File

@ -5,8 +5,8 @@ use gpui::{
elements::{Empty, MouseEventHandler, Overlay},
geometry::{rect::RectF, vector::Vector2F},
scene::{MouseDown, MouseDrag},
CursorStyle, Element, ElementBox, EventContext, MouseButton, MutableAppContext, RenderContext,
View, WeakViewHandle,
AppContext, CursorStyle, Element, ElementBox, EventContext, MouseButton, 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 {

View File

@ -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();

View File

@ -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")

View File

@ -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);

View File

@ -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"))

View File

@ -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";
@ -641,7 +641,7 @@ mod tests {
#[gpui::test]
fn test_long_lines_with_character_spanning_max_expansion_column(
cx: &mut gpui::MutableAppContext,
cx: &mut gpui::AppContext,
) {
let max_expansion_column = 8;
let input = "abcdefg⋯hij";
@ -657,7 +657,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() {

View File

@ -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 {

View File

@ -42,8 +42,8 @@ use gpui::{
platform::CursorStyle,
serde_json::{self, json},
AnyViewHandle, AppContext, AsyncAppContext, ClipboardItem, Element, ElementBox, Entity,
ModelHandle, MouseButton, MutableAppContext, RenderContext, Subscription, Task, View,
ViewContext, ViewHandle, WeakViewHandle,
ModelHandle, MouseButton, RenderContext, Subscription, Task, View, ViewContext, ViewHandle,
WeakViewHandle,
};
use highlight_matching_bracket::refresh_matching_bracket_highlights;
use hover_popover::{hide_hover, HideHover, HoverState};
@ -295,7 +295,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);
@ -1314,7 +1314,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 +6168,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 +6194,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 +6226,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))
}
@ -6766,7 +6766,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()));
}
}

View File

@ -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));

View File

@ -32,8 +32,8 @@ use gpui::{
platform::CursorStyle,
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,
Modifiers, MouseButton, MouseButtonEvent, MouseMovedEvent, MouseRegion, PaintContext, Quad,
SceneBuilder, SizeConstraint, ViewContext, WeakViewHandle,
};
use itertools::Itertools;
use json::json;
@ -103,14 +103,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 +2522,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 +2542,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| {

View File

@ -4,7 +4,7 @@ use gpui::{
elements::{Flex, MouseEventHandler, Padding, Text},
impl_internal_actions,
platform::CursorStyle,
Axis, Element, ElementBox, ModelHandle, MouseButton, MutableAppContext, RenderContext, Task,
AppContext, Axis, Element, ElementBox, ModelHandle, MouseButton, RenderContext, Task,
ViewContext,
};
use language::{Bias, DiagnosticEntry, DiagnosticSeverity};
@ -36,7 +36,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);

View File

@ -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(""),

View File

@ -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);

View File

@ -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);
}

View File

@ -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()

View File

@ -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));

View File

@ -9,7 +9,7 @@ use std::{
use gpui::{
geometry::vector::{vec2f, Vector2F},
Axis, MutableAppContext, Task, ViewContext,
Axis, AppContext, 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

View File

@ -1,5 +1,5 @@
use gpui::{
actions, geometry::vector::Vector2F, impl_internal_actions, Axis, MutableAppContext,
actions, geometry::vector::Vector2F, impl_internal_actions, Axis, AppContext,
ViewContext,
};
use language::Bias;
@ -32,7 +32,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);

View File

@ -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> {

View File

@ -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);

View File

@ -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, ClipboardItem, AppContext, PromptLevel, 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();

View File

@ -11,8 +11,8 @@ 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,
serde_json, AnyViewHandle, AppContext, Element, ElementBox, Entity, ModelHandle, PromptLevel,
RenderContext, Task, View, ViewContext, ViewHandle,
};
use isahc::Request;
use language::Buffer;
@ -35,7 +35,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);

View File

@ -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);
}

View File

@ -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

View File

@ -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);

View File

@ -1,4 +1,4 @@
use crate::{Action, App, ForegroundPlatform, MutableAppContext};
use crate::{Action, App, AppContext, ForegroundPlatform};
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;

View File

@ -19,9 +19,8 @@ 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,
KeyDownEvent, ModelContext, ModelHandle, Platform, ReadModelWith, ReadViewWith, RenderContext,
Task, UpdateModel, UpdateView, View, ViewContext, ViewHandle, WeakHandle,
};
use collections::BTreeMap;
@ -30,7 +29,7 @@ use super::{
};
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,
@ -48,7 +47,7 @@ impl TestAppContext {
first_entity_id: usize,
function_name: String,
) -> Self {
let mut cx = MutableAppContext::new(
let mut cx = AppContext::new(
foreground,
background,
platform,
@ -149,15 +148,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.
@ -194,7 +193,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> {
@ -202,7 +201,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> {
@ -396,7 +395,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)
}
}
@ -424,7 +423,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)
}
}
@ -513,7 +512,7 @@ impl<T: Entity> ModelHandle<T> {
loop {
{
let cx = cx.borrow();
let cx = cx.as_ref();
let cx = &*cx;
if predicate(
handle
.upgrade(cx)
@ -600,7 +599,7 @@ impl<T: View> ViewHandle<T> {
loop {
{
let cx = cx.borrow();
let cx = cx.as_ref();
let cx = &*cx;
if predicate(
handle
.upgrade(cx)

View File

@ -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::{AnyView, AppContext, InputHandler};
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)
})
}

View File

@ -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.,

View File

@ -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);

View File

@ -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(), || {

View File

@ -17,7 +17,7 @@ use std::{
use crate::{
platform::{self, Dispatcher},
util, MutableAppContext,
util, AppContext,
};
pub enum Foreground {
@ -931,7 +931,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);

View File

@ -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();

View File

@ -1,5 +1,5 @@
use crate::{
app::{AppContext, MutableAppContext, WindowInvalidation},
app::WindowInvalidation,
elements::Element,
font_cache::FontCache,
geometry::rect::RectF,
@ -10,11 +10,11 @@ use crate::{
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,
Appearance, AssetCache, ElementBox, Entity, FontSystem, ModelHandle, MouseButton,
MouseMovedEvent, MouseRegion, MouseRegionId, MouseState, ParentId, ReadModel, ReadView,
RenderContext, RenderParams, SceneBuilder, UpgradeModelHandle, UpgradeViewHandle, View,
ViewHandle, WeakModelHandle, WeakViewHandle,
};
use anyhow::bail;
use collections::{HashMap, HashSet};
@ -56,7 +56,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 +80,7 @@ impl Presenter {
&mut self,
invalidation: &mut WindowInvalidation,
appearance: Appearance,
cx: &mut MutableAppContext,
cx: &mut AppContext,
) {
cx.start_frame();
self.appearance = appearance;
@ -111,7 +111,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 +138,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 +169,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 +180,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 +206,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 +234,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 +557,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 +595,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 +692,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 +804,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 +871,7 @@ impl<'a> EventContext<'a> {
}
impl<'a> Deref for EventContext<'a> {
type Target = MutableAppContext;
type Target = AppContext;
fn deref(&self) -> &Self::Target {
self.app

View File

@ -18,7 +18,7 @@ use crate::{
executor::{self, ExecutorEvent},
platform,
util::CwdBacktrace,
Element, ElementBox, Entity, FontCache, Handle, MutableAppContext, Platform, RenderContext,
AppContext, Element, ElementBox, Entity, FontCache, Handle, Platform, RenderContext,
Subscription, TestAppContext, View,
};
@ -40,7 +40,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,

View File

@ -660,7 +660,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 +721,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();

View File

@ -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);
}

View File

@ -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, AppContext, Entity, MouseButton, 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
}

View File

@ -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,

View File

@ -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,
);
}

View File

@ -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);

View File

@ -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() {

View File

@ -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();

View File

@ -89,6 +89,6 @@ fn main() {
});
}
fn quit(_: &Quit, cx: &mut gpui::MutableAppContext) {
fn quit(_: &Quit, cx: &mut gpui::AppContext) {
cx.platform().quit();
}

View File

@ -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 {

View File

@ -4,8 +4,8 @@ use gpui::{
geometry::vector::{vec2f, Vector2F},
keymap_matcher::KeymapContext,
platform::CursorStyle,
AnyViewHandle, AppContext, Axis, Entity, MouseButton, MouseState, MutableAppContext,
RenderContext, Task, View, ViewContext, ViewHandle, WeakViewHandle,
AnyViewHandle, AppContext, Axis, Entity, MouseButton, 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);

View File

@ -18,8 +18,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,
@ -414,7 +414,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>| Self {
worktrees: Default::default(),
@ -6519,7 +6519,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 {
@ -6537,7 +6537,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

View File

@ -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,

View File

@ -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 {
@ -1896,7 +1893,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) {

View File

@ -13,8 +13,8 @@ use gpui::{
impl_internal_actions,
keymap_matcher::KeymapContext,
platform::CursorStyle,
AppContext, ClipboardItem, Element, ElementBox, Entity, ModelHandle, MouseButton,
MutableAppContext, PromptLevel, RenderContext, Task, View, ViewContext, ViewHandle,
AppContext, ClipboardItem, Element, ElementBox, Entity, ModelHandle, MouseButton, PromptLevel,
RenderContext, Task, View, ViewContext, ViewHandle,
};
use menu::{Confirm, SelectNext, SelectPrev};
use project::{Entry, EntryKind, Project, ProjectEntryId, ProjectPath, Worktree, WorktreeId};
@ -132,7 +132,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);

View File

@ -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);
}

View File

@ -4,7 +4,7 @@ use fuzzy::{StringMatch, StringMatchCandidate};
use gpui::{
actions,
elements::{ChildView, Flex, ParentElement},
AnyViewHandle, Element, ElementBox, Entity, MutableAppContext, RenderContext, Task, View,
AnyViewHandle, Element, ElementBox, Entity, AppContext, RenderContext, Task, View,
ViewContext, ViewHandle,
};
use highlighted_workspace_location::HighlightedWorkspaceLocation;
@ -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);
}

View File

@ -6,8 +6,7 @@ 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,
Entity, MouseButton, RenderContext, Subscription, Task, View, ViewContext, ViewHandle,
};
use project::search::SearchQuery;
use serde::Deserialize;
@ -31,7 +30,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 +44,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)) {

View File

@ -10,8 +10,8 @@ use editor::{
use futures::StreamExt;
use gpui::{
actions, elements::*, platform::CursorStyle, Action, AnyViewHandle, AppContext, ElementBox,
Entity, ModelContext, ModelHandle, MouseButton, MutableAppContext, RenderContext, Subscription,
Task, View, ViewContext, ViewHandle, WeakModelHandle, WeakViewHandle,
Entity, ModelContext, ModelHandle, MouseButton, RenderContext, Subscription, Task, View,
ViewContext, ViewHandle, WeakModelHandle, WeakViewHandle,
};
use menu::Confirm;
use project::{search::SearchQuery, Project};
@ -36,7 +36,7 @@ actions!(project_search, [SearchInNew, ToggleFocus]);
#[derive(Default)]
struct ActiveSearches(HashMap<WeakModelHandle<Project>, WeakViewHandle<ProjectSearchView>>);
pub fn init(cx: &mut MutableAppContext) {
pub fn init(cx: &mut AppContext) {
cx.set_global(ActiveSearches::default());
cx.add_action(ProjectSearchView::deploy);
cx.add_action(ProjectSearchBar::search);
@ -50,7 +50,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::<ProjectSearchBar>() {
if search_bar.update(cx, |search_bar, cx| {

View File

@ -1,11 +1,11 @@
pub use buffer_search::BufferSearchBar;
use gpui::{actions, Action, MutableAppContext};
use gpui::{actions, Action, AppContext};
pub use project_search::{ProjectSearchBar, ProjectSearchView};
pub mod buffer_search;
pub mod project_search;
pub fn init(cx: &mut MutableAppContext) {
pub fn init(cx: &mut AppContext) {
buffer_search::init(cx);
project_search::init(cx);
}

View File

@ -2,7 +2,7 @@ use crate::{parse_json_with_comments, Settings};
use anyhow::{Context, Result};
use assets::Assets;
use collections::BTreeMap;
use gpui::{keymap_matcher::Binding, MutableAppContext};
use gpui::{keymap_matcher::Binding, AppContext};
use schemars::{
gen::{SchemaGenerator, SchemaSettings},
schema::{InstanceType, Schema, SchemaObject, SingleOrVec, SubschemaValidation},
@ -41,7 +41,7 @@ impl JsonSchema for KeymapAction {
struct ActionWithData(Box<str>, Box<RawValue>);
impl KeymapFileContent {
pub fn load_defaults(cx: &mut MutableAppContext) {
pub fn load_defaults(cx: &mut AppContext) {
for path in ["keymaps/default.json", "keymaps/vim.json"] {
Self::load(path, cx).unwrap();
}
@ -51,13 +51,13 @@ impl KeymapFileContent {
}
}
pub fn load(asset_path: &str, cx: &mut MutableAppContext) -> Result<()> {
pub fn load(asset_path: &str, cx: &mut AppContext) -> Result<()> {
let content = Assets::get(asset_path).unwrap().data;
let content_str = std::str::from_utf8(content.as_ref()).unwrap();
parse_json_with_comments::<Self>(content_str)?.add_to_cx(cx)
}
pub fn add_to_cx(self, cx: &mut MutableAppContext) -> Result<()> {
pub fn add_to_cx(self, cx: &mut AppContext) -> Result<()> {
for KeymapBlock { context, bindings } in self.0 {
let bindings = bindings
.into_iter()

View File

@ -2,7 +2,7 @@ use crate::{update_settings_file, watched_json::WatchedJsonFile, SettingsFileCon
use anyhow::Result;
use assets::Assets;
use fs::Fs;
use gpui::{AssetSource, MutableAppContext};
use gpui::{AppContext, AssetSource};
use std::{io::ErrorKind, path::Path, sync::Arc};
// TODO: Switch SettingsFile to open a worktree and buffer for synchronization
@ -49,7 +49,7 @@ impl SettingsFile {
}
pub fn update(
cx: &mut MutableAppContext,
cx: &mut AppContext,
update: impl 'static + Send + FnOnce(&mut SettingsFileContent),
) {
let this = cx.global::<SettingsFile>();
@ -211,7 +211,7 @@ mod tests {
}
fn assert_key_bindings_for<'a>(
cx: &mut MutableAppContext,
cx: &mut AppContext,
actions: Vec<(&'static str, &'a dyn Action)>,
line: u32,
) {

View File

@ -1,6 +1,6 @@
use fs::Fs;
use futures::StreamExt;
use gpui::{executor, MutableAppContext};
use gpui::{executor, AppContext};
use postage::sink::Sink as _;
use postage::{prelude::Stream, watch};
use serde::Deserialize;
@ -67,7 +67,7 @@ pub fn watch_files(
settings_file: WatchedJsonFile<SettingsFileContent>,
theme_registry: Arc<ThemeRegistry>,
keymap_file: WatchedJsonFile<KeymapFileContent>,
cx: &mut MutableAppContext,
cx: &mut AppContext,
) {
watch_settings_file(defaults, settings_file, theme_registry, cx);
watch_keymap_file(keymap_file, cx);
@ -77,7 +77,7 @@ pub(crate) fn watch_settings_file(
defaults: Settings,
mut file: WatchedJsonFile<SettingsFileContent>,
theme_registry: Arc<ThemeRegistry>,
cx: &mut MutableAppContext,
cx: &mut AppContext,
) {
settings_updated(&defaults, file.0.borrow().clone(), &theme_registry, cx);
cx.spawn(|mut cx| async move {
@ -88,7 +88,7 @@ pub(crate) fn watch_settings_file(
.detach();
}
fn keymap_updated(content: KeymapFileContent, cx: &mut MutableAppContext) {
fn keymap_updated(content: KeymapFileContent, cx: &mut AppContext) {
cx.clear_bindings();
KeymapFileContent::load_defaults(cx);
content.add_to_cx(cx).log_err();
@ -98,7 +98,7 @@ fn settings_updated(
defaults: &Settings,
content: SettingsFileContent,
theme_registry: &Arc<ThemeRegistry>,
cx: &mut MutableAppContext,
cx: &mut AppContext,
) {
let mut settings = defaults.clone();
settings.set_user_settings(content, theme_registry, cx.font_cache());
@ -106,7 +106,7 @@ fn settings_updated(
cx.refresh_windows();
}
fn watch_keymap_file(mut file: WatchedJsonFile<KeymapFileContent>, cx: &mut MutableAppContext) {
fn watch_keymap_file(mut file: WatchedJsonFile<KeymapFileContent>, cx: &mut AppContext) {
cx.spawn(|mut cx| async move {
let mut settings_subscription = None;
while let Some(content) = file.0.recv().await {

View File

@ -1,4 +1,4 @@
use gpui::MutableAppContext;
use gpui::AppContext;
#[derive(Debug, Default)]
pub struct StaffMode(pub bool);
@ -13,8 +13,8 @@ impl std::ops::Deref for StaffMode {
/// Despite what the type system requires me to tell you, the init function will only be called a once
/// as soon as we know that the staff mode is enabled.
pub fn staff_mode<F: FnMut(&mut MutableAppContext) + 'static>(
cx: &mut MutableAppContext,
pub fn staff_mode<F: FnMut(&mut AppContext) + 'static>(
cx: &mut AppContext,
mut init: F,
) {
if **cx.default_global::<StaffMode>() {
@ -32,8 +32,8 @@ pub fn staff_mode<F: FnMut(&mut MutableAppContext) + 'static>(
/// Immediately checks and runs the init function if the staff mode is not enabled.
/// This is only included for symettry with staff_mode() above
pub fn not_staff_mode<F: FnOnce(&mut MutableAppContext) + 'static>(
cx: &mut MutableAppContext,
pub fn not_staff_mode<F: FnOnce(&mut AppContext) + 'static>(
cx: &mut AppContext,
init: F,
) {
if !**cx.default_global::<StaffMode>() {

View File

@ -1,7 +1,7 @@
use context_menu::{ContextMenu, ContextMenuItem};
use gpui::{
elements::*, impl_internal_actions, CursorStyle, Element, ElementBox, Entity, MouseButton,
MutableAppContext, RenderContext, View, ViewContext, ViewHandle, WeakModelHandle,
AppContext, RenderContext, View, ViewContext, ViewHandle, WeakModelHandle,
WeakViewHandle,
};
use settings::Settings;
@ -21,7 +21,7 @@ pub struct FocusTerminal {
impl_internal_actions!(terminal, [FocusTerminal, DeployTerminalMenu]);
pub fn init(cx: &mut MutableAppContext) {
pub fn init(cx: &mut AppContext) {
cx.add_action(TerminalButton::deploy_terminal_menu);
cx.add_action(TerminalButton::focus_terminal);
}

View File

@ -16,8 +16,8 @@ use gpui::{
geometry::vector::Vector2F,
impl_actions, impl_internal_actions,
keymap_matcher::{KeymapContext, Keystroke},
AnyViewHandle, AppContext, Element, ElementBox, Entity, ModelHandle, MutableAppContext, Task,
View, ViewContext, ViewHandle, WeakViewHandle,
AnyViewHandle, AppContext, Element, ElementBox, Entity, ModelHandle, Task, View, ViewContext,
ViewHandle, WeakViewHandle,
};
use project::{LocalWorktree, Project};
use serde::Deserialize;
@ -68,7 +68,7 @@ impl_actions!(terminal, [SendText, SendKeystroke]);
impl_internal_actions!(project_panel, [DeployContextMenu]);
pub fn init(cx: &mut MutableAppContext) {
pub fn init(cx: &mut AppContext) {
cx.add_action(TerminalView::deploy);
register_deserializable_item::<TerminalView>(cx);

View File

@ -1,7 +1,7 @@
use fuzzy::{match_strings, StringMatch, StringMatchCandidate};
use gpui::{
actions, elements::*, AnyViewHandle, AppContext, Element, ElementBox, Entity, MouseState,
MutableAppContext, RenderContext, View, ViewContext, ViewHandle,
RenderContext, View, ViewContext, ViewHandle,
};
use picker::{Picker, PickerDelegate};
use settings::{settings_file::SettingsFile, Settings};
@ -22,7 +22,7 @@ pub struct ThemeSelector {
actions!(theme_selector, [Toggle, Reload]);
pub fn init(app_state: Arc<AppState>, cx: &mut MutableAppContext) {
pub fn init(app_state: Arc<AppState>, cx: &mut AppContext) {
Picker::<ThemeSelector>::init(cx);
cx.add_action({
let theme_registry = app_state.themes.clone();
@ -83,7 +83,7 @@ impl ThemeSelector {
}
#[cfg(debug_assertions)]
pub fn reload(themes: Arc<ThemeRegistry>, cx: &mut MutableAppContext) {
pub fn reload(themes: Arc<ThemeRegistry>, cx: &mut AppContext) {
let current_theme_name = cx.global::<Settings>().theme.meta.name.clone();
themes.clear();
match themes.get(&current_theme_name) {
@ -131,7 +131,7 @@ impl ThemeSelector {
}
}
fn set_theme(theme: Arc<Theme>, cx: &mut MutableAppContext) {
fn set_theme(theme: Arc<Theme>, cx: &mut AppContext) {
cx.update_global::<Settings, _, _>(|settings, cx| {
settings.theme = theme;
cx.refresh_windows();
@ -243,7 +243,7 @@ impl PickerDelegate for ThemeSelector {
impl Entity for ThemeSelector {
type Event = Event;
fn release(&mut self, cx: &mut MutableAppContext) {
fn release(&mut self, cx: &mut AppContext) {
if !self.selection_completed {
Self::set_theme(self.original_theme.clone(), cx);
}

View File

@ -6,8 +6,8 @@ use gpui::{
Padding, ParentElement,
},
fonts::TextStyle,
AppContext, Border, Element, Entity, ModelHandle, MutableAppContext, Quad, RenderContext, Task,
View, ViewContext, ViewHandle, WeakViewHandle,
AppContext, Border, Element, Entity, ModelHandle, Quad, RenderContext, Task, View, ViewContext,
ViewHandle, WeakViewHandle,
};
use project::Project;
use settings::Settings;
@ -16,7 +16,7 @@ use workspace::{item::Item, register_deserializable_item, Pane, Workspace};
actions!(theme, [DeployThemeTestbench]);
pub fn init(cx: &mut MutableAppContext) {
pub fn init(cx: &mut AppContext) {
cx.add_action(ThemeTestbench::deploy);
register_deserializable_item::<ThemeTestbench>(cx)

View File

@ -1,15 +1,15 @@
use editor::{EditorBlurred, EditorFocused, EditorMode, EditorReleased, Event};
use gpui::MutableAppContext;
use gpui::AppContext;
use crate::{state::Mode, Vim};
pub fn init(cx: &mut MutableAppContext) {
pub fn init(cx: &mut AppContext) {
cx.subscribe_global(focused).detach();
cx.subscribe_global(blurred).detach();
cx.subscribe_global(released).detach();
}
fn focused(EditorFocused(editor): &EditorFocused, cx: &mut MutableAppContext) {
fn focused(EditorFocused(editor): &EditorFocused, cx: &mut AppContext) {
Vim::update(cx, |vim, cx| {
if let Some(previously_active_editor) = vim
.active_editor
@ -48,7 +48,7 @@ fn focused(EditorFocused(editor): &EditorFocused, cx: &mut MutableAppContext) {
});
}
fn blurred(EditorBlurred(editor): &EditorBlurred, cx: &mut MutableAppContext) {
fn blurred(EditorBlurred(editor): &EditorBlurred, cx: &mut AppContext) {
Vim::update(cx, |vim, cx| {
if let Some(previous_editor) = vim.active_editor.clone() {
if previous_editor == editor.clone() {
@ -59,7 +59,7 @@ fn blurred(EditorBlurred(editor): &EditorBlurred, cx: &mut MutableAppContext) {
})
}
fn released(EditorReleased(editor): &EditorReleased, cx: &mut MutableAppContext) {
fn released(EditorReleased(editor): &EditorReleased, cx: &mut AppContext) {
cx.update_default_global(|vim: &mut Vim, _| {
if let Some(previous_editor) = vim.active_editor.clone() {
if previous_editor == editor.clone() {
@ -69,7 +69,7 @@ fn released(EditorReleased(editor): &EditorReleased, cx: &mut MutableAppContext)
});
}
fn local_selections_changed(newest_empty: bool, cx: &mut MutableAppContext) {
fn local_selections_changed(newest_empty: bool, cx: &mut AppContext) {
Vim::update(cx, |vim, cx| {
if vim.enabled && vim.state.mode == Mode::Normal && !newest_empty {
vim.switch_mode(Mode::Visual { line: false }, false, cx)

View File

@ -1,12 +1,12 @@
use crate::{state::Mode, Vim};
use editor::{scroll::autoscroll::Autoscroll, Bias};
use gpui::{actions, MutableAppContext, ViewContext};
use gpui::{actions, AppContext, ViewContext};
use language::SelectionGoal;
use workspace::Workspace;
actions!(vim, [NormalBefore]);
pub fn init(cx: &mut MutableAppContext) {
pub fn init(cx: &mut AppContext) {
cx.add_action(normal_before);
}

View File

@ -5,7 +5,7 @@ use editor::{
display_map::{DisplaySnapshot, ToDisplayPoint},
movement, Bias, CharKind, DisplayPoint, ToOffset,
};
use gpui::{actions, impl_actions, MutableAppContext};
use gpui::{actions, impl_actions, AppContext};
use language::{Point, Selection, SelectionGoal};
use serde::Deserialize;
use workspace::Workspace;
@ -80,7 +80,7 @@ actions!(
);
impl_actions!(vim, [NextWordStart, NextWordEnd, PreviousWordStart]);
pub fn init(cx: &mut MutableAppContext) {
pub fn init(cx: &mut AppContext) {
cx.add_action(|_: &mut Workspace, _: &Left, cx: _| motion(Motion::Left, cx));
cx.add_action(|_: &mut Workspace, _: &Backspace, cx: _| motion(Motion::Backspace, cx));
cx.add_action(|_: &mut Workspace, _: &Down, cx: _| motion(Motion::Down, cx));
@ -116,7 +116,7 @@ pub fn init(cx: &mut MutableAppContext) {
cx.add_action(|_: &mut Workspace, &NextLineStart, cx: _| motion(Motion::NextLineStart, cx))
}
pub(crate) fn motion(motion: Motion, cx: &mut MutableAppContext) {
pub(crate) fn motion(motion: Motion, cx: &mut AppContext) {
if let Some(Operator::Namespace(_))
| Some(Operator::FindForward { .. })
| Some(Operator::FindBackward { .. }) = Vim::read(cx).active_operator()

View File

@ -16,7 +16,7 @@ use editor::{
scroll::{autoscroll::Autoscroll, scroll_amount::ScrollAmount},
Anchor, Bias, ClipboardSelection, DisplayPoint, Editor,
};
use gpui::{actions, impl_actions, MutableAppContext, ViewContext};
use gpui::{actions, impl_actions, AppContext, ViewContext};
use language::{AutoindentMode, Point, SelectionGoal};
use log::error;
use serde::Deserialize;
@ -50,7 +50,7 @@ actions!(
impl_actions!(vim, [Scroll]);
pub fn init(cx: &mut MutableAppContext) {
pub fn init(cx: &mut AppContext) {
cx.add_action(insert_after);
cx.add_action(insert_first_non_whitespace);
cx.add_action(insert_end_of_line);
@ -94,7 +94,7 @@ pub fn normal_motion(
motion: Motion,
operator: Option<Operator>,
times: usize,
cx: &mut MutableAppContext,
cx: &mut AppContext,
) {
Vim::update(cx, |vim, cx| {
match operator {
@ -110,7 +110,7 @@ pub fn normal_motion(
});
}
pub fn normal_object(object: Object, cx: &mut MutableAppContext) {
pub fn normal_object(object: Object, cx: &mut AppContext) {
Vim::update(cx, |vim, cx| {
match vim.state.operator_stack.pop() {
Some(Operator::Object { around }) => match vim.state.operator_stack.pop() {
@ -129,7 +129,7 @@ pub fn normal_object(object: Object, cx: &mut MutableAppContext) {
})
}
fn move_cursor(vim: &mut Vim, motion: Motion, times: usize, cx: &mut MutableAppContext) {
fn move_cursor(vim: &mut Vim, motion: Motion, times: usize, cx: &mut AppContext) {
vim.update_active_editor(cx, |editor, cx| {
editor.change_selections(Some(Autoscroll::fit()), cx, |s| {
s.move_cursors_with(|map, cursor, goal| {
@ -424,7 +424,7 @@ fn scroll(editor: &mut Editor, amount: &ScrollAmount, cx: &mut ViewContext<Edito
}
}
pub(crate) fn normal_replace(text: Arc<str>, cx: &mut MutableAppContext) {
pub(crate) fn normal_replace(text: Arc<str>, cx: &mut AppContext) {
Vim::update(cx, |vim, cx| {
vim.update_active_editor(cx, |editor, cx| {
editor.transact(cx, |editor, cx| {

View File

@ -3,10 +3,10 @@ use editor::{
char_kind, display_map::DisplaySnapshot, movement, scroll::autoscroll::Autoscroll, CharKind,
DisplayPoint,
};
use gpui::MutableAppContext;
use gpui::AppContext;
use language::Selection;
pub fn change_motion(vim: &mut Vim, motion: Motion, times: usize, cx: &mut MutableAppContext) {
pub fn change_motion(vim: &mut Vim, motion: Motion, times: usize, cx: &mut AppContext) {
// Some motions ignore failure when switching to normal mode
let mut motion_succeeded = matches!(
motion,
@ -38,7 +38,7 @@ pub fn change_motion(vim: &mut Vim, motion: Motion, times: usize, cx: &mut Mutab
}
}
pub fn change_object(vim: &mut Vim, object: Object, around: bool, cx: &mut MutableAppContext) {
pub fn change_object(vim: &mut Vim, object: Object, around: bool, cx: &mut AppContext) {
let mut objects_found = false;
vim.update_active_editor(cx, |editor, cx| {
// We are swapping to insert mode anyway. Just set the line end clipping behavior now

View File

@ -1,9 +1,9 @@
use crate::{motion::Motion, object::Object, utils::copy_selections_content, Vim};
use collections::{HashMap, HashSet};
use editor::{display_map::ToDisplayPoint, scroll::autoscroll::Autoscroll, Bias};
use gpui::MutableAppContext;
use gpui::AppContext;
pub fn delete_motion(vim: &mut Vim, motion: Motion, times: usize, cx: &mut MutableAppContext) {
pub fn delete_motion(vim: &mut Vim, motion: Motion, times: usize, cx: &mut AppContext) {
vim.update_active_editor(cx, |editor, cx| {
editor.transact(cx, |editor, cx| {
editor.set_clip_at_line_ends(false, cx);
@ -36,7 +36,7 @@ pub fn delete_motion(vim: &mut Vim, motion: Motion, times: usize, cx: &mut Mutab
});
}
pub fn delete_object(vim: &mut Vim, object: Object, around: bool, cx: &mut MutableAppContext) {
pub fn delete_object(vim: &mut Vim, object: Object, around: bool, cx: &mut AppContext) {
vim.update_active_editor(cx, |editor, cx| {
editor.transact(cx, |editor, cx| {
editor.set_clip_at_line_ends(false, cx);

View File

@ -1,8 +1,8 @@
use crate::{motion::Motion, object::Object, utils::copy_selections_content, Vim};
use collections::HashMap;
use gpui::MutableAppContext;
use gpui::AppContext;
pub fn yank_motion(vim: &mut Vim, motion: Motion, times: usize, cx: &mut MutableAppContext) {
pub fn yank_motion(vim: &mut Vim, motion: Motion, times: usize, cx: &mut AppContext) {
vim.update_active_editor(cx, |editor, cx| {
editor.transact(cx, |editor, cx| {
editor.set_clip_at_line_ends(false, cx);
@ -25,7 +25,7 @@ pub fn yank_motion(vim: &mut Vim, motion: Motion, times: usize, cx: &mut Mutable
});
}
pub fn yank_object(vim: &mut Vim, object: Object, around: bool, cx: &mut MutableAppContext) {
pub fn yank_object(vim: &mut Vim, object: Object, around: bool, cx: &mut AppContext) {
vim.update_active_editor(cx, |editor, cx| {
editor.transact(cx, |editor, cx| {
editor.set_clip_at_line_ends(false, cx);

View File

@ -1,7 +1,7 @@
use std::ops::Range;
use editor::{char_kind, display_map::DisplaySnapshot, movement, Bias, CharKind, DisplayPoint};
use gpui::{actions, impl_actions, MutableAppContext};
use gpui::{actions, impl_actions, AppContext};
use language::Selection;
use serde::Deserialize;
use workspace::Workspace;
@ -43,7 +43,7 @@ actions!(
);
impl_actions!(vim, [Word]);
pub fn init(cx: &mut MutableAppContext) {
pub fn init(cx: &mut AppContext) {
cx.add_action(
|_: &mut Workspace, &Word { ignore_punctuation }: &Word, cx: _| {
object(Object::Word { ignore_punctuation }, cx)
@ -61,7 +61,7 @@ pub fn init(cx: &mut MutableAppContext) {
cx.add_action(|_: &mut Workspace, _: &AngleBrackets, cx: _| object(Object::AngleBrackets, cx));
}
fn object(object: Object, cx: &mut MutableAppContext) {
fn object(object: Object, cx: &mut AppContext) {
match Vim::read(cx).state.mode {
Mode::Normal => normal_object(object, cx),
Mode::Visual { .. } => visual_object(object, cx),

View File

@ -1,7 +1,7 @@
use editor::{ClipboardSelection, Editor};
use gpui::{ClipboardItem, MutableAppContext};
use gpui::{AppContext, ClipboardItem};
pub fn copy_selections_content(editor: &mut Editor, linewise: bool, cx: &mut MutableAppContext) {
pub fn copy_selections_content(editor: &mut Editor, linewise: bool, cx: &mut AppContext) {
let selections = editor.selections.all_adjusted(cx);
let buffer = editor.buffer().read(cx).snapshot(cx);
let mut text = String::new();

View File

@ -15,7 +15,7 @@ use std::sync::Arc;
use collections::CommandPaletteFilter;
use editor::{Bias, Cancel, Editor, EditorMode};
use gpui::{
actions, impl_actions, MutableAppContext, Subscription, ViewContext, ViewHandle, WeakViewHandle,
actions, impl_actions, AppContext, Subscription, ViewContext, ViewHandle, WeakViewHandle,
};
use language::CursorShape;
use motion::Motion;
@ -38,7 +38,7 @@ struct Number(u8);
actions!(vim, [Tab, Enter]);
impl_actions!(vim, [Number, SwitchMode, PushOperator]);
pub fn init(cx: &mut MutableAppContext) {
pub fn init(cx: &mut AppContext) {
editor_events::init(cx);
normal::init(cx);
visual::init(cx);
@ -65,7 +65,7 @@ pub fn init(cx: &mut MutableAppContext) {
// Otherwise forward cancel on to the editor
let vim = Vim::read(cx);
if vim.state.mode != Mode::Normal || vim.active_operator().is_some() {
MutableAppContext::defer(cx, |cx| {
AppContext::defer(cx, |cx| {
Vim::update(cx, |state, cx| {
state.switch_mode(Mode::Normal, false, cx);
});
@ -95,7 +95,7 @@ pub fn init(cx: &mut MutableAppContext) {
.detach();
}
pub fn observe_keystrokes(window_id: usize, cx: &mut MutableAppContext) {
pub fn observe_keystrokes(window_id: usize, cx: &mut AppContext) {
cx.observe_keystrokes(window_id, |_keystroke, _result, handled_by, cx| {
if let Some(handled_by) = handled_by {
// Keystroke is handled by the vim system, so continue forward
@ -131,20 +131,20 @@ pub struct Vim {
}
impl Vim {
fn read(cx: &mut MutableAppContext) -> &Self {
fn read(cx: &mut AppContext) -> &Self {
cx.default_global()
}
fn update<F, S>(cx: &mut MutableAppContext, update: F) -> S
fn update<F, S>(cx: &mut AppContext, update: F) -> S
where
F: FnOnce(&mut Self, &mut MutableAppContext) -> S,
F: FnOnce(&mut Self, &mut AppContext) -> S,
{
cx.update_default_global(update)
}
fn update_active_editor<S>(
&self,
cx: &mut MutableAppContext,
cx: &mut AppContext,
update: impl FnOnce(&mut Editor, &mut ViewContext<Editor>) -> S,
) -> Option<S> {
self.active_editor
@ -153,7 +153,7 @@ impl Vim {
.map(|ae| ae.update(cx, update))
}
fn switch_mode(&mut self, mode: Mode, leave_selections: bool, cx: &mut MutableAppContext) {
fn switch_mode(&mut self, mode: Mode, leave_selections: bool, cx: &mut AppContext) {
self.state.mode = mode;
self.state.operator_stack.clear();
@ -188,12 +188,12 @@ impl Vim {
}
}
fn push_operator(&mut self, operator: Operator, cx: &mut MutableAppContext) {
fn push_operator(&mut self, operator: Operator, cx: &mut AppContext) {
self.state.operator_stack.push(operator);
self.sync_vim_settings(cx);
}
fn push_number(&mut self, Number(number): &Number, cx: &mut MutableAppContext) {
fn push_number(&mut self, Number(number): &Number, cx: &mut AppContext) {
if let Some(Operator::Number(current_number)) = self.active_operator() {
self.pop_operator(cx);
self.push_operator(Operator::Number(current_number * 10 + *number as usize), cx);
@ -202,14 +202,14 @@ impl Vim {
}
}
fn pop_operator(&mut self, cx: &mut MutableAppContext) -> Operator {
fn pop_operator(&mut self, cx: &mut AppContext) -> Operator {
let popped_operator = self.state.operator_stack.pop()
.expect("Operator popped when no operator was on the stack. This likely means there is an invalid keymap config");
self.sync_vim_settings(cx);
popped_operator
}
fn pop_number_operator(&mut self, cx: &mut MutableAppContext) -> usize {
fn pop_number_operator(&mut self, cx: &mut AppContext) -> usize {
let mut times = 1;
if let Some(Operator::Number(number)) = self.active_operator() {
times = number;
@ -218,7 +218,7 @@ impl Vim {
times
}
fn clear_operator(&mut self, cx: &mut MutableAppContext) {
fn clear_operator(&mut self, cx: &mut AppContext) {
self.state.operator_stack.clear();
self.sync_vim_settings(cx);
}
@ -227,7 +227,7 @@ impl Vim {
self.state.operator_stack.last().copied()
}
fn active_editor_input_ignored(text: Arc<str>, cx: &mut MutableAppContext) {
fn active_editor_input_ignored(text: Arc<str>, cx: &mut AppContext) {
if text.is_empty() {
return;
}
@ -248,7 +248,7 @@ impl Vim {
}
}
fn set_enabled(&mut self, enabled: bool, cx: &mut MutableAppContext) {
fn set_enabled(&mut self, enabled: bool, cx: &mut AppContext) {
if self.enabled != enabled {
self.enabled = enabled;
self.state = Default::default();
@ -259,7 +259,7 @@ impl Vim {
}
}
fn sync_vim_settings(&self, cx: &mut MutableAppContext) {
fn sync_vim_settings(&self, cx: &mut AppContext) {
let state = &self.state;
let cursor_shape = state.cursor_shape();
@ -291,7 +291,7 @@ impl Vim {
}
}
fn unhook_vim_settings(&self, editor: ViewHandle<Editor>, cx: &mut MutableAppContext) {
fn unhook_vim_settings(&self, editor: ViewHandle<Editor>, cx: &mut AppContext) {
editor.update(cx, |editor, cx| {
editor.set_cursor_shape(CursorShape::Bar, cx);
editor.set_clip_at_line_ends(false, cx);

View File

@ -4,7 +4,7 @@ use collections::HashMap;
use editor::{
display_map::ToDisplayPoint, movement, scroll::autoscroll::Autoscroll, Bias, ClipboardSelection,
};
use gpui::{actions, MutableAppContext, ViewContext};
use gpui::{actions, AppContext, ViewContext};
use language::{AutoindentMode, SelectionGoal};
use workspace::Workspace;
@ -18,14 +18,14 @@ use crate::{
actions!(vim, [VisualDelete, VisualChange, VisualYank, VisualPaste]);
pub fn init(cx: &mut MutableAppContext) {
pub fn init(cx: &mut AppContext) {
cx.add_action(change);
cx.add_action(delete);
cx.add_action(yank);
cx.add_action(paste);
}
pub fn visual_motion(motion: Motion, times: usize, cx: &mut MutableAppContext) {
pub fn visual_motion(motion: Motion, times: usize, cx: &mut AppContext) {
Vim::update(cx, |vim, cx| {
vim.update_active_editor(cx, |editor, cx| {
editor.change_selections(Some(Autoscroll::fit()), cx, |s| {
@ -56,7 +56,7 @@ pub fn visual_motion(motion: Motion, times: usize, cx: &mut MutableAppContext) {
});
}
pub fn visual_object(object: Object, cx: &mut MutableAppContext) {
pub fn visual_object(object: Object, cx: &mut AppContext) {
Vim::update(cx, |vim, cx| {
if let Operator::Object { around } = vim.pop_operator(cx) {
vim.update_active_editor(cx, |editor, cx| {
@ -313,7 +313,7 @@ pub fn paste(_: &mut Workspace, _: &VisualPaste, cx: &mut ViewContext<Workspace>
});
}
pub(crate) fn visual_replace(text: Arc<str>, line: bool, cx: &mut MutableAppContext) {
pub(crate) fn visual_replace(text: Arc<str>, line: bool, cx: &mut AppContext) {
Vim::update(cx, |vim, cx| {
vim.update_active_editor(cx, |editor, cx| {
editor.transact(cx, |editor, cx| {
@ -648,7 +648,7 @@ mod test {
cx.assert_state(
indoc! {"
The quick brown
the
the
ˇfox jumps over
dog"},
Mode::Normal,

View File

@ -2,7 +2,7 @@ use fuzzy::{match_strings, StringMatch, StringMatchCandidate};
use gpui::{
actions,
elements::{ChildView, Element as _, Label},
AnyViewHandle, Entity, MutableAppContext, View, ViewContext, ViewHandle,
AnyViewHandle, Entity, AppContext, View, ViewContext, ViewHandle,
};
use picker::{Picker, PickerDelegate};
use settings::{settings_file::SettingsFile, BaseKeymap, Settings};
@ -16,7 +16,7 @@ pub struct BaseKeymapSelector {
actions!(welcome, [ToggleBaseKeymapSelector]);
pub fn init(cx: &mut MutableAppContext) {
pub fn init(cx: &mut AppContext) {
Picker::<BaseKeymapSelector>::init(cx);
cx.add_action({
move |workspace, _: &ToggleBaseKeymapSelector, cx| BaseKeymapSelector::toggle(workspace, cx)

View File

@ -5,7 +5,7 @@ use std::sync::Arc;
use db::kvp::KEY_VALUE_STORE;
use gpui::{
elements::{Flex, Label, ParentElement},
Element, ElementBox, Entity, MutableAppContext, Subscription, View, ViewContext,
Element, ElementBox, Entity, AppContext, Subscription, View, ViewContext,
};
use settings::{settings_file::SettingsFile, Settings};
@ -18,7 +18,7 @@ use crate::base_keymap_picker::ToggleBaseKeymapSelector;
pub const FIRST_OPEN: &str = "first_open";
pub fn init(cx: &mut MutableAppContext) {
pub fn init(cx: &mut AppContext) {
cx.add_action(|workspace: &mut Workspace, _: &Welcome, cx| {
let welcome_page = cx.add_view(WelcomePage::new);
workspace.add_item(Box::new(welcome_page), cx)
@ -27,7 +27,7 @@ pub fn init(cx: &mut MutableAppContext) {
base_keymap_picker::init(cx);
}
pub fn show_welcome_experience(app_state: &Arc<AppState>, cx: &mut MutableAppContext) {
pub fn show_welcome_experience(app_state: &Arc<AppState>, cx: &mut AppContext) {
open_new(&app_state, cx, |workspace, cx| {
workspace.toggle_sidebar(SidebarSide::Left, cx);
let welcome_page = cx.add_view(|cx| WelcomePage::new(cx));

Some files were not shown because too many files have changed in this diff Show More