mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-08 07:35:01 +03:00
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:
parent
dd00966cc6
commit
de9bf6dfbd
@ -3,7 +3,7 @@ use editor::Editor;
|
|||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, elements::*, platform::CursorStyle, Action, AppContext, Entity, ModelHandle,
|
actions, elements::*, platform::CursorStyle, Action, AppContext, Entity, ModelHandle,
|
||||||
MouseButton, MutableAppContext, RenderContext, View, ViewContext, ViewHandle,
|
MouseButton, RenderContext, View, ViewContext, ViewHandle,
|
||||||
};
|
};
|
||||||
use language::{LanguageRegistry, LanguageServerBinaryStatus};
|
use language::{LanguageRegistry, LanguageServerBinaryStatus};
|
||||||
use project::{LanguageServerProgress, Project};
|
use project::{LanguageServerProgress, Project};
|
||||||
@ -46,7 +46,7 @@ struct Content {
|
|||||||
action: Option<Box<dyn Action>>,
|
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::show_error_message);
|
||||||
cx.add_action(ActivityIndicator::dismiss_error_message);
|
cx.add_action(ActivityIndicator::dismiss_error_message);
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ use client::{ZED_APP_PATH, ZED_APP_VERSION, ZED_SECRET_CLIENT_TOKEN};
|
|||||||
use db::kvp::KEY_VALUE_STORE;
|
use db::kvp::KEY_VALUE_STORE;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, platform::AppVersion, AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle,
|
actions, platform::AppVersion, AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle,
|
||||||
MutableAppContext, Task, WeakViewHandle,
|
Task, WeakViewHandle,
|
||||||
};
|
};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
@ -49,7 +49,7 @@ impl Entity for AutoUpdater {
|
|||||||
type Event = ();
|
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()) {
|
if let Some(version) = (*ZED_APP_VERSION).or_else(|| cx.platform().app_version().ok()) {
|
||||||
let server_url = server_url;
|
let server_url = server_url;
|
||||||
let auto_updater = cx.add_model(|cx| {
|
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(
|
pub fn notify_of_any_new_update(
|
||||||
workspace: WeakViewHandle<Workspace>,
|
workspace: WeakViewHandle<Workspace>,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
) -> Option<()> {
|
) -> Option<()> {
|
||||||
let updater = AutoUpdater::get(cx)?;
|
let updater = AutoUpdater::get(cx)?;
|
||||||
let version = updater.read(cx).current_version;
|
let version = updater.read(cx).current_version;
|
||||||
@ -124,7 +124,7 @@ pub fn notify_of_any_new_update(
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl AutoUpdater {
|
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()
|
cx.default_global::<Option<ModelHandle<Self>>>().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
self.pane_focused = pane_focused;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,15 +10,15 @@ use futures::{future::Shared, FutureExt};
|
|||||||
use postage::watch;
|
use postage::watch;
|
||||||
|
|
||||||
use gpui::{
|
use gpui::{
|
||||||
AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, MutableAppContext,
|
AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, Subscription, Task,
|
||||||
Subscription, Task, WeakModelHandle,
|
WeakModelHandle,
|
||||||
};
|
};
|
||||||
use project::Project;
|
use project::Project;
|
||||||
|
|
||||||
pub use participant::ParticipantLocation;
|
pub use participant::ParticipantLocation;
|
||||||
pub use room::Room;
|
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));
|
let active_call = cx.add_model(|cx| ActiveCall::new(client, user_store, cx));
|
||||||
cx.set_global(active_call);
|
cx.set_global(active_call);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ use collections::{BTreeMap, HashMap, HashSet};
|
|||||||
use fs::Fs;
|
use fs::Fs;
|
||||||
use futures::{FutureExt, StreamExt};
|
use futures::{FutureExt, StreamExt};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
AsyncAppContext, Entity, ModelContext, ModelHandle, MutableAppContext, Task, WeakModelHandle,
|
AsyncAppContext, Entity, ModelContext, ModelHandle, AppContext, Task, WeakModelHandle,
|
||||||
};
|
};
|
||||||
use language::LanguageRegistry;
|
use language::LanguageRegistry;
|
||||||
use live_kit_client::{LocalTrackPublication, LocalVideoTrack, RemoteVideoTrackUpdate};
|
use live_kit_client::{LocalTrackPublication, LocalVideoTrack, RemoteVideoTrackUpdate};
|
||||||
@ -64,7 +64,7 @@ pub struct Room {
|
|||||||
impl Entity for Room {
|
impl Entity for Room {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
|
|
||||||
fn release(&mut self, cx: &mut MutableAppContext) {
|
fn release(&mut self, cx: &mut AppContext) {
|
||||||
if self.status.is_online() {
|
if self.status.is_online() {
|
||||||
self.leave_internal(cx).detach_and_log_err(cx);
|
self.leave_internal(cx).detach_and_log_err(cx);
|
||||||
}
|
}
|
||||||
@ -72,7 +72,7 @@ impl Entity for Room {
|
|||||||
|
|
||||||
fn app_will_quit(
|
fn app_will_quit(
|
||||||
&mut self,
|
&mut self,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
) -> Option<Pin<Box<dyn Future<Output = ()>>>> {
|
) -> Option<Pin<Box<dyn Future<Output = ()>>>> {
|
||||||
if self.status.is_online() {
|
if self.status.is_online() {
|
||||||
let leave = self.leave_internal(cx);
|
let leave = self.leave_internal(cx);
|
||||||
@ -176,7 +176,7 @@ impl Room {
|
|||||||
initial_project: Option<ModelHandle<Project>>,
|
initial_project: Option<ModelHandle<Project>>,
|
||||||
client: Arc<Client>,
|
client: Arc<Client>,
|
||||||
user_store: ModelHandle<UserStore>,
|
user_store: ModelHandle<UserStore>,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
) -> Task<Result<ModelHandle<Self>>> {
|
) -> Task<Result<ModelHandle<Self>>> {
|
||||||
cx.spawn(|mut cx| async move {
|
cx.spawn(|mut cx| async move {
|
||||||
let response = client.request(proto::CreateRoom {}).await?;
|
let response = client.request(proto::CreateRoom {}).await?;
|
||||||
@ -219,7 +219,7 @@ impl Room {
|
|||||||
call: &IncomingCall,
|
call: &IncomingCall,
|
||||||
client: Arc<Client>,
|
client: Arc<Client>,
|
||||||
user_store: ModelHandle<UserStore>,
|
user_store: ModelHandle<UserStore>,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
) -> Task<Result<ModelHandle<Self>>> {
|
) -> Task<Result<ModelHandle<Self>>> {
|
||||||
let room_id = call.room_id;
|
let room_id = call.room_id;
|
||||||
cx.spawn(|mut cx| async move {
|
cx.spawn(|mut cx| async move {
|
||||||
@ -257,7 +257,7 @@ impl Room {
|
|||||||
self.leave_internal(cx)
|
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() {
|
if self.status.is_offline() {
|
||||||
return Task::ready(Err(anyhow!("room is offline")));
|
return Task::ready(Err(anyhow!("room is offline")));
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ use gpui::{
|
|||||||
actions,
|
actions,
|
||||||
serde_json::{self, Value},
|
serde_json::{self, Value},
|
||||||
AnyModelHandle, AnyViewHandle, AnyWeakModelHandle, AnyWeakViewHandle, AppContext, AppVersion,
|
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 lazy_static::lazy_static;
|
||||||
use parking_lot::RwLock;
|
use parking_lot::RwLock;
|
||||||
@ -67,7 +67,7 @@ pub const CONNECTION_TIMEOUT: Duration = Duration::from_secs(5);
|
|||||||
|
|
||||||
actions!(client, [SignIn, SignOut]);
|
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({
|
cx.add_global_action({
|
||||||
let client = client.clone();
|
let client = client.clone();
|
||||||
move |_: &SignIn, cx| {
|
move |_: &SignIn, cx| {
|
||||||
|
@ -15,7 +15,7 @@ use gpui::{
|
|||||||
geometry::{rect::RectF, vector::vec2f, PathBuilder},
|
geometry::{rect::RectF, vector::vec2f, PathBuilder},
|
||||||
impl_internal_actions,
|
impl_internal_actions,
|
||||||
json::{self, ToJson},
|
json::{self, ToJson},
|
||||||
CursorStyle, Entity, ImageData, ModelHandle, MouseButton, MutableAppContext, RenderContext,
|
AppContext, CursorStyle, Entity, ImageData, ModelHandle, MouseButton, RenderContext,
|
||||||
Subscription, View, ViewContext, ViewHandle, WeakViewHandle,
|
Subscription, View, ViewContext, ViewHandle, WeakViewHandle,
|
||||||
};
|
};
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
@ -40,7 +40,7 @@ impl_internal_actions!(collab, [LeaveCall]);
|
|||||||
#[derive(Copy, Clone, PartialEq)]
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
pub(crate) struct LeaveCall;
|
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_collaborator_list_popover);
|
||||||
cx.add_action(CollabTitlebarItem::toggle_contacts_popover);
|
cx.add_action(CollabTitlebarItem::toggle_contacts_popover);
|
||||||
cx.add_action(CollabTitlebarItem::share_project);
|
cx.add_action(CollabTitlebarItem::share_project);
|
||||||
|
@ -13,13 +13,13 @@ mod sharing_status_indicator;
|
|||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use call::ActiveCall;
|
use call::ActiveCall;
|
||||||
pub use collab_titlebar_item::{CollabTitlebarItem, ToggleContactsMenu};
|
pub use collab_titlebar_item::{CollabTitlebarItem, ToggleContactsMenu};
|
||||||
use gpui::{actions, MutableAppContext, Task};
|
use gpui::{actions, AppContext, Task};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use workspace::{AppState, JoinProject, ToggleFollow, Workspace};
|
use workspace::{AppState, JoinProject, ToggleFollow, Workspace};
|
||||||
|
|
||||||
actions!(collab, [ToggleScreenSharing]);
|
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);
|
collab_titlebar_item::init(cx);
|
||||||
contact_notification::init(cx);
|
contact_notification::init(cx);
|
||||||
contact_list::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() {
|
if let Some(room) = ActiveCall::global(cx).read(cx).room().cloned() {
|
||||||
let toggle_screen_sharing = room.update(cx, |room, cx| {
|
let toggle_screen_sharing = room.update(cx, |room, cx| {
|
||||||
if room.is_screen_sharing() {
|
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 project_id = action.project_id;
|
||||||
let follow_user_id = action.follow_user_id;
|
let follow_user_id = action.follow_user_id;
|
||||||
cx.spawn(|mut cx| async move {
|
cx.spawn(|mut cx| async move {
|
||||||
let existing_workspace = cx.update(|cx| {
|
let existing_workspace = cx.update(|cx| {
|
||||||
cx.window_ids()
|
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| {
|
.find(|workspace| {
|
||||||
workspace.read(cx).project().read(cx).remote_id() == Some(project_id)
|
workspace.read(cx).project().read(cx).remote_id() == Some(project_id)
|
||||||
})
|
})
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
use client::{ContactRequestStatus, User, UserStore};
|
use client::{ContactRequestStatus, User, UserStore};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
elements::*, AnyViewHandle, AppContext, Entity, ModelHandle, MouseState, MutableAppContext,
|
elements::*, AnyViewHandle, AppContext, Entity, ModelHandle, MouseState, RenderContext, Task,
|
||||||
RenderContext, Task, View, ViewContext, ViewHandle,
|
View, ViewContext, ViewHandle,
|
||||||
};
|
};
|
||||||
use picker::{Picker, PickerDelegate};
|
use picker::{Picker, PickerDelegate};
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use util::TryFutureExt;
|
use util::TryFutureExt;
|
||||||
|
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
Picker::<ContactFinder>::init(cx);
|
Picker::<ContactFinder>::init(cx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,8 +10,8 @@ use gpui::{
|
|||||||
geometry::{rect::RectF, vector::vec2f},
|
geometry::{rect::RectF, vector::vec2f},
|
||||||
impl_actions, impl_internal_actions,
|
impl_actions, impl_internal_actions,
|
||||||
keymap_matcher::KeymapContext,
|
keymap_matcher::KeymapContext,
|
||||||
AppContext, CursorStyle, Entity, ModelHandle, MouseButton, MutableAppContext, PromptLevel,
|
AppContext, CursorStyle, Entity, ModelHandle, MouseButton, PromptLevel, RenderContext,
|
||||||
RenderContext, Subscription, View, ViewContext, ViewHandle,
|
Subscription, View, ViewContext, ViewHandle,
|
||||||
};
|
};
|
||||||
use menu::{Confirm, SelectNext, SelectPrev};
|
use menu::{Confirm, SelectNext, SelectPrev};
|
||||||
use project::Project;
|
use project::Project;
|
||||||
@ -24,7 +24,7 @@ use workspace::{JoinProject, OpenSharedScreen};
|
|||||||
impl_actions!(contact_list, [RemoveContact, RespondToContactRequest]);
|
impl_actions!(contact_list, [RemoveContact, RespondToContactRequest]);
|
||||||
impl_internal_actions!(contact_list, [ToggleExpanded, Call]);
|
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::remove_contact);
|
||||||
cx.add_action(ContactList::respond_to_contact_request);
|
cx.add_action(ContactList::respond_to_contact_request);
|
||||||
cx.add_action(ContactList::cancel);
|
cx.add_action(ContactList::cancel);
|
||||||
|
@ -3,14 +3,14 @@ use std::sync::Arc;
|
|||||||
use crate::notifications::render_user_notification;
|
use crate::notifications::render_user_notification;
|
||||||
use client::{ContactEventKind, User, UserStore};
|
use client::{ContactEventKind, User, UserStore};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
elements::*, impl_internal_actions, Entity, ModelHandle, MutableAppContext, RenderContext,
|
elements::*, impl_internal_actions, Entity, ModelHandle, AppContext, RenderContext,
|
||||||
View, ViewContext,
|
View, ViewContext,
|
||||||
};
|
};
|
||||||
use workspace::notifications::Notification;
|
use workspace::notifications::Notification;
|
||||||
|
|
||||||
impl_internal_actions!(contact_notifications, [Dismiss, RespondToContactRequest]);
|
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::dismiss);
|
||||||
cx.add_action(ContactNotification::respond_to_contact_request);
|
cx.add_action(ContactNotification::respond_to_contact_request);
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use crate::{contact_finder::ContactFinder, contact_list::ContactList, ToggleContactsMenu};
|
use crate::{contact_finder::ContactFinder, contact_list::ContactList, ToggleContactsMenu};
|
||||||
use client::UserStore;
|
use client::UserStore;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, elements::*, Entity, ModelHandle, MouseButton, MutableAppContext, RenderContext, View,
|
actions, elements::*, AppContext, Entity, ModelHandle, MouseButton, RenderContext, View,
|
||||||
ViewContext, ViewHandle,
|
ViewContext, ViewHandle,
|
||||||
};
|
};
|
||||||
use project::Project;
|
use project::Project;
|
||||||
@ -9,7 +9,7 @@ use settings::Settings;
|
|||||||
|
|
||||||
actions!(contacts_popover, [ToggleContactFinder]);
|
actions!(contacts_popover, [ToggleContactFinder]);
|
||||||
|
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
cx.add_action(ContactsPopover::toggle_contact_finder);
|
cx.add_action(ContactsPopover::toggle_contact_finder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ use futures::StreamExt;
|
|||||||
use gpui::{
|
use gpui::{
|
||||||
elements::*,
|
elements::*,
|
||||||
geometry::{rect::RectF, vector::vec2f},
|
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,
|
View, ViewContext, WindowBounds, WindowKind, WindowOptions,
|
||||||
};
|
};
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
@ -13,7 +13,7 @@ use workspace::JoinProject;
|
|||||||
|
|
||||||
impl_internal_actions!(incoming_call_notification, [RespondToCall]);
|
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);
|
cx.add_action(IncomingCallNotification::respond_to_call);
|
||||||
|
|
||||||
let mut incoming_call = ActiveCall::global(cx).read(cx).incoming();
|
let mut incoming_call = ActiveCall::global(cx).read(cx).incoming();
|
||||||
|
@ -5,7 +5,7 @@ use gpui::{
|
|||||||
actions,
|
actions,
|
||||||
elements::*,
|
elements::*,
|
||||||
geometry::{rect::RectF, vector::vec2f},
|
geometry::{rect::RectF, vector::vec2f},
|
||||||
CursorStyle, Entity, MouseButton, MutableAppContext, RenderContext, View, ViewContext,
|
CursorStyle, Entity, MouseButton, AppContext, RenderContext, View, ViewContext,
|
||||||
WindowBounds, WindowKind, WindowOptions,
|
WindowBounds, WindowKind, WindowOptions,
|
||||||
};
|
};
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
@ -14,7 +14,7 @@ use workspace::JoinProject;
|
|||||||
|
|
||||||
actions!(project_shared_notification, [DismissProject]);
|
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::join);
|
||||||
cx.add_action(ProjectSharedNotification::dismiss);
|
cx.add_action(ProjectSharedNotification::dismiss);
|
||||||
|
|
||||||
|
@ -2,13 +2,13 @@ use call::ActiveCall;
|
|||||||
use gpui::{
|
use gpui::{
|
||||||
color::Color,
|
color::Color,
|
||||||
elements::{MouseEventHandler, Svg},
|
elements::{MouseEventHandler, Svg},
|
||||||
Appearance, Element, ElementBox, Entity, MouseButton, MutableAppContext, RenderContext, View,
|
Appearance, Element, ElementBox, Entity, MouseButton, AppContext, RenderContext, View,
|
||||||
};
|
};
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
|
|
||||||
use crate::ToggleScreenSharing;
|
use crate::ToggleScreenSharing;
|
||||||
|
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
let active_call = ActiveCall::global(cx);
|
let active_call = ActiveCall::global(cx);
|
||||||
|
|
||||||
let mut status_indicator = None;
|
let mut status_indicator = None;
|
||||||
|
@ -4,7 +4,7 @@ use gpui::{
|
|||||||
actions,
|
actions,
|
||||||
elements::{ChildView, Flex, Label, ParentElement},
|
elements::{ChildView, Flex, Label, ParentElement},
|
||||||
keymap_matcher::Keystroke,
|
keymap_matcher::Keystroke,
|
||||||
Action, AnyViewHandle, Element, Entity, MouseState, MutableAppContext, RenderContext, View,
|
Action, AnyViewHandle, Element, Entity, MouseState, AppContext, RenderContext, View,
|
||||||
ViewContext, ViewHandle,
|
ViewContext, ViewHandle,
|
||||||
};
|
};
|
||||||
use picker::{Picker, PickerDelegate};
|
use picker::{Picker, PickerDelegate};
|
||||||
@ -12,7 +12,7 @@ use settings::Settings;
|
|||||||
use std::cmp;
|
use std::cmp;
|
||||||
use workspace::Workspace;
|
use workspace::Workspace;
|
||||||
|
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
cx.add_action(CommandPalette::toggle);
|
cx.add_action(CommandPalette::toggle);
|
||||||
Picker::<CommandPalette>::init(cx);
|
Picker::<CommandPalette>::init(cx);
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
use gpui::{
|
use gpui::{
|
||||||
elements::*, geometry::vector::Vector2F, impl_internal_actions, keymap_matcher::KeymapContext,
|
elements::*, geometry::vector::Vector2F, impl_internal_actions, keymap_matcher::KeymapContext,
|
||||||
platform::CursorStyle, Action, AnyViewHandle, AppContext, Axis, Entity, MouseButton,
|
platform::CursorStyle, Action, AnyViewHandle, AppContext, Axis, Entity, MouseButton,
|
||||||
MouseState, MutableAppContext, RenderContext, SizeConstraint, Subscription, View, ViewContext,
|
MouseState, RenderContext, SizeConstraint, Subscription, View, ViewContext,
|
||||||
};
|
};
|
||||||
use menu::*;
|
use menu::*;
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use std::{any::TypeId, borrow::Cow, time::Duration};
|
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)]
|
#[derive(Copy, Clone, PartialEq)]
|
||||||
struct Clicked;
|
struct Clicked;
|
||||||
|
|
||||||
impl_internal_actions!(context_menu, [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_first);
|
||||||
cx.add_action(ContextMenu::select_last);
|
cx.add_action(ContextMenu::select_last);
|
||||||
cx.add_action(ContextMenu::select_next);
|
cx.add_action(ContextMenu::select_next);
|
||||||
|
@ -6,10 +6,7 @@ use async_compression::futures::bufread::GzipDecoder;
|
|||||||
use async_tar::Archive;
|
use async_tar::Archive;
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use futures::{future::Shared, Future, FutureExt, TryFutureExt};
|
use futures::{future::Shared, Future, FutureExt, TryFutureExt};
|
||||||
use gpui::{
|
use gpui::{actions, AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, Task};
|
||||||
actions, AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, MutableAppContext,
|
|
||||||
Task,
|
|
||||||
};
|
|
||||||
use language::{point_from_lsp, point_to_lsp, Anchor, Bias, Buffer, Language, ToPointUtf16};
|
use language::{point_from_lsp, point_to_lsp, Anchor, Bias, Buffer, Language, ToPointUtf16};
|
||||||
use log::{debug, error};
|
use log::{debug, error};
|
||||||
use lsp::LanguageServer;
|
use lsp::LanguageServer;
|
||||||
@ -34,7 +31,7 @@ actions!(copilot_auth, [SignIn, SignOut]);
|
|||||||
const COPILOT_NAMESPACE: &'static str = "copilot";
|
const COPILOT_NAMESPACE: &'static str = "copilot";
|
||||||
actions!(copilot, [NextSuggestion, PreviousSuggestion, Reinstall]);
|
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.
|
// Disable Copilot for stable releases.
|
||||||
if *cx.global::<ReleaseChannel>() == ReleaseChannel::Stable {
|
if *cx.global::<ReleaseChannel>() == ReleaseChannel::Stable {
|
||||||
cx.update_global::<collections::CommandPaletteFilter, _, _>(|filter, _cx| {
|
cx.update_global::<collections::CommandPaletteFilter, _, _>(|filter, _cx| {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use crate::{request::PromptUserDeviceFlow, Copilot, Status};
|
use crate::{request::PromptUserDeviceFlow, Copilot, Status};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
elements::*, geometry::rect::RectF, ClipboardItem, Element, Entity, MutableAppContext, View,
|
elements::*, geometry::rect::RectF, ClipboardItem, Element, Entity, AppContext, View,
|
||||||
ViewContext, ViewHandle, WindowKind, WindowOptions,
|
ViewContext, ViewHandle, WindowKind, WindowOptions,
|
||||||
};
|
};
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
@ -14,7 +14,7 @@ struct OpenGithub;
|
|||||||
|
|
||||||
const COPILOT_SIGN_UP_URL: &'static str = "https://github.com/features/copilot";
|
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 copilot = Copilot::global(cx).unwrap();
|
||||||
|
|
||||||
let mut code_verification: Option<ViewHandle<CopilotCodeVerification>> = None;
|
let mut code_verification: Option<ViewHandle<CopilotCodeVerification>> = None;
|
||||||
@ -57,7 +57,7 @@ pub fn init(cx: &mut MutableAppContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn create_copilot_auth_window(
|
fn create_copilot_auth_window(
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
status: &Status,
|
status: &Status,
|
||||||
code_verification: &mut Option<ViewHandle<CopilotCodeVerification>>,
|
code_verification: &mut Option<ViewHandle<CopilotCodeVerification>>,
|
||||||
) {
|
) {
|
||||||
|
@ -3,8 +3,8 @@ use std::sync::Arc;
|
|||||||
use context_menu::{ContextMenu, ContextMenuItem};
|
use context_menu::{ContextMenu, ContextMenuItem};
|
||||||
use editor::Editor;
|
use editor::Editor;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
elements::*, impl_internal_actions, CursorStyle, Element, ElementBox, Entity, MouseButton,
|
elements::*, impl_internal_actions, AppContext, CursorStyle, Element, ElementBox, Entity,
|
||||||
MouseState, MutableAppContext, RenderContext, Subscription, View, ViewContext, ViewHandle,
|
MouseButton, MouseState, RenderContext, Subscription, View, ViewContext, ViewHandle,
|
||||||
};
|
};
|
||||||
use settings::{settings_file::SettingsFile, Settings};
|
use settings::{settings_file::SettingsFile, Settings};
|
||||||
use workspace::{
|
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(CopilotButton::deploy_copilot_menu);
|
||||||
cx.add_action(
|
cx.add_action(
|
||||||
|_: &mut CopilotButton, action: &ToggleCopilotForLanguage, cx| {
|
|_: &mut CopilotButton, action: &ToggleCopilotForLanguage, cx| {
|
||||||
|
@ -4,7 +4,7 @@ pub mod query;
|
|||||||
// Re-export
|
// Re-export
|
||||||
pub use anyhow;
|
pub use anyhow;
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use gpui::MutableAppContext;
|
use gpui::AppContext;
|
||||||
pub use indoc::indoc;
|
pub use indoc::indoc;
|
||||||
pub use lazy_static;
|
pub use lazy_static;
|
||||||
use parking_lot::{Mutex, RwLock};
|
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
|
where
|
||||||
F: Future<Output = anyhow::Result<()>> + Send,
|
F: Future<Output = anyhow::Result<()>> + Send,
|
||||||
{
|
{
|
||||||
|
@ -11,8 +11,8 @@ use editor::{
|
|||||||
};
|
};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, elements::*, fonts::TextStyle, impl_internal_actions, serde_json, AnyViewHandle,
|
actions, elements::*, fonts::TextStyle, impl_internal_actions, serde_json, AnyViewHandle,
|
||||||
AppContext, Entity, ModelHandle, MutableAppContext, RenderContext, Task, View, ViewContext,
|
AppContext, Entity, ModelHandle, RenderContext, Task, View, ViewContext, ViewHandle,
|
||||||
ViewHandle, WeakViewHandle,
|
WeakViewHandle,
|
||||||
};
|
};
|
||||||
use language::{
|
use language::{
|
||||||
Anchor, Bias, Buffer, Diagnostic, DiagnosticEntry, DiagnosticSeverity, Point, Selection,
|
Anchor, Bias, Buffer, Diagnostic, DiagnosticEntry, DiagnosticSeverity, Point, Selection,
|
||||||
@ -41,7 +41,7 @@ impl_internal_actions!(diagnostics, [Jump]);
|
|||||||
|
|
||||||
const CONTEXT_LINE_COUNT: u32 = 1;
|
const CONTEXT_LINE_COUNT: u32 = 1;
|
||||||
|
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
cx.add_action(ProjectDiagnosticsEditor::deploy);
|
cx.add_action(ProjectDiagnosticsEditor::deploy);
|
||||||
items::init(cx);
|
items::init(cx);
|
||||||
}
|
}
|
||||||
@ -1176,10 +1176,7 @@ mod tests {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn editor_blocks(
|
fn editor_blocks(editor: &ViewHandle<Editor>, cx: &mut AppContext) -> Vec<(u32, String)> {
|
||||||
editor: &ViewHandle<Editor>,
|
|
||||||
cx: &mut MutableAppContext,
|
|
||||||
) -> Vec<(u32, String)> {
|
|
||||||
let mut presenter = cx.build_presenter(editor.id(), 0., Default::default());
|
let mut presenter = cx.build_presenter(editor.id(), 0., Default::default());
|
||||||
let mut cx = presenter.build_layout_context(Default::default(), false, cx);
|
let mut cx = presenter.build_layout_context(Default::default(), false, cx);
|
||||||
cx.render(editor, |editor, cx| {
|
cx.render(editor, |editor, cx| {
|
||||||
|
@ -2,7 +2,7 @@ use collections::HashSet;
|
|||||||
use editor::{Editor, GoToDiagnostic};
|
use editor::{Editor, GoToDiagnostic};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
elements::*, platform::CursorStyle, serde_json, Entity, ModelHandle, MouseButton,
|
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 language::Diagnostic;
|
||||||
use project::Project;
|
use project::Project;
|
||||||
@ -17,7 +17,7 @@ pub struct DiagnosticIndicator {
|
|||||||
_observe_active_editor: Option<Subscription>,
|
_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);
|
cx.add_action(DiagnosticIndicator::go_to_next_diagnostic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,8 +5,8 @@ use gpui::{
|
|||||||
elements::{Empty, MouseEventHandler, Overlay},
|
elements::{Empty, MouseEventHandler, Overlay},
|
||||||
geometry::{rect::RectF, vector::Vector2F},
|
geometry::{rect::RectF, vector::Vector2F},
|
||||||
scene::{MouseDown, MouseDrag},
|
scene::{MouseDown, MouseDrag},
|
||||||
CursorStyle, Element, ElementBox, EventContext, MouseButton, MutableAppContext, RenderContext,
|
AppContext, CursorStyle, Element, ElementBox, EventContext, MouseButton, RenderContext, View,
|
||||||
View, WeakViewHandle,
|
WeakViewHandle,
|
||||||
};
|
};
|
||||||
|
|
||||||
const DEAD_ZONE: f32 = 4.;
|
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 {
|
if let Some(State::Dragging {
|
||||||
payload, window_id, ..
|
payload, window_id, ..
|
||||||
}) = &self.currently_dragged
|
}) = &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() {
|
if let Some(State::Dragging { window_id, .. }) = self.currently_dragged.take() {
|
||||||
self.notify_containers_for_window(window_id, cx);
|
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| {
|
self.containers.retain(|container| {
|
||||||
if let Some(container) = container.upgrade(cx) {
|
if let Some(container) = container.upgrade(cx) {
|
||||||
if container.window_id() == window_id {
|
if container.window_id() == window_id {
|
||||||
|
@ -843,7 +843,7 @@ pub fn next_rows(display_row: u32, display_map: &DisplaySnapshot) -> impl Iterat
|
|||||||
pub mod tests {
|
pub mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{movement, test::marked_display_snapshot};
|
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 language::{Buffer, Language, LanguageConfig, SelectionGoal};
|
||||||
use rand::{prelude::*, Rng};
|
use rand::{prelude::*, Rng};
|
||||||
use smol::stream::StreamExt;
|
use smol::stream::StreamExt;
|
||||||
@ -1117,7 +1117,7 @@ pub mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test(retries = 5)]
|
#[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().set_block_on_ticks(usize::MAX..=usize::MAX);
|
||||||
cx.foreground().forbid_parking();
|
cx.foreground().forbid_parking();
|
||||||
|
|
||||||
@ -1210,7 +1210,7 @@ pub mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_text_chunks(cx: &mut gpui::MutableAppContext) {
|
fn test_text_chunks(cx: &mut gpui::AppContext) {
|
||||||
cx.set_global(Settings::test(cx));
|
cx.set_global(Settings::test(cx));
|
||||||
let text = sample_text(6, 6, 'a');
|
let text = sample_text(6, 6, 'a');
|
||||||
let buffer = MultiBuffer::build_simple(&text, cx);
|
let buffer = MultiBuffer::build_simple(&text, cx);
|
||||||
@ -1509,9 +1509,9 @@ pub mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_clip_point(cx: &mut gpui::MutableAppContext) {
|
fn test_clip_point(cx: &mut gpui::AppContext) {
|
||||||
cx.set_global(Settings::test(cx));
|
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);
|
let (unmarked_snapshot, mut markers) = marked_display_snapshot(text, cx);
|
||||||
|
|
||||||
match bias {
|
match bias {
|
||||||
@ -1558,10 +1558,10 @@ pub mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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));
|
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);
|
let (mut unmarked_snapshot, markers) = marked_display_snapshot(text, cx);
|
||||||
unmarked_snapshot.clip_at_line_ends = true;
|
unmarked_snapshot.clip_at_line_ends = true;
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@ -1577,7 +1577,7 @@ pub mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
let text = "✅\t\tα\nβ\t\n🏀β\t\tγ";
|
let text = "✅\t\tα\nβ\t\n🏀β\t\tγ";
|
||||||
let buffer = MultiBuffer::build_simple(text, cx);
|
let buffer = MultiBuffer::build_simple(text, cx);
|
||||||
@ -1638,7 +1638,7 @@ pub mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_max_point(cx: &mut gpui::MutableAppContext) {
|
fn test_max_point(cx: &mut gpui::AppContext) {
|
||||||
cx.set_global(Settings::test(cx));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple("aaa\n\t\tbbb", cx);
|
let buffer = MultiBuffer::build_simple("aaa\n\t\tbbb", cx);
|
||||||
let font_cache = cx.font_cache();
|
let font_cache = cx.font_cache();
|
||||||
@ -1687,7 +1687,7 @@ pub mod tests {
|
|||||||
rows: Range<u32>,
|
rows: Range<u32>,
|
||||||
map: &ModelHandle<DisplayMap>,
|
map: &ModelHandle<DisplayMap>,
|
||||||
theme: &'a SyntaxTheme,
|
theme: &'a SyntaxTheme,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
) -> Vec<(String, Option<Color>)> {
|
) -> Vec<(String, Option<Color>)> {
|
||||||
chunks(rows, map, theme, cx)
|
chunks(rows, map, theme, cx)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
@ -1699,7 +1699,7 @@ pub mod tests {
|
|||||||
rows: Range<u32>,
|
rows: Range<u32>,
|
||||||
map: &ModelHandle<DisplayMap>,
|
map: &ModelHandle<DisplayMap>,
|
||||||
theme: &'a SyntaxTheme,
|
theme: &'a SyntaxTheme,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
) -> Vec<(String, Option<Color>, Option<Color>)> {
|
) -> Vec<(String, Option<Color>, Option<Color>)> {
|
||||||
let snapshot = map.update(cx, |map, cx| map.snapshot(cx));
|
let snapshot = map.update(cx, |map, cx| map.snapshot(cx));
|
||||||
let mut chunks: Vec<(String, Option<Color>, Option<Color>)> = Vec::new();
|
let mut chunks: Vec<(String, Option<Color>, Option<Color>)> = Vec::new();
|
||||||
|
@ -1015,7 +1015,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_basic_blocks(cx: &mut gpui::MutableAppContext) {
|
fn test_basic_blocks(cx: &mut gpui::AppContext) {
|
||||||
cx.set_global(Settings::test(cx));
|
cx.set_global(Settings::test(cx));
|
||||||
|
|
||||||
let family_id = cx
|
let family_id = cx
|
||||||
@ -1191,7 +1191,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
|
|
||||||
let family_id = cx
|
let family_id = cx
|
||||||
@ -1241,7 +1241,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test(iterations = 100)]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
|
|
||||||
let operations = env::var("OPERATIONS")
|
let operations = env::var("OPERATIONS")
|
||||||
|
@ -1214,7 +1214,7 @@ mod tests {
|
|||||||
use Bias::{Left, Right};
|
use Bias::{Left, Right};
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_basic_folds(cx: &mut gpui::MutableAppContext) {
|
fn test_basic_folds(cx: &mut gpui::AppContext) {
|
||||||
cx.set_global(Settings::test(cx));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple(&sample_text(5, 6, 'a'), cx);
|
let buffer = MultiBuffer::build_simple(&sample_text(5, 6, 'a'), cx);
|
||||||
let subscription = buffer.update(cx, |buffer, _| buffer.subscribe());
|
let subscription = buffer.update(cx, |buffer, _| buffer.subscribe());
|
||||||
@ -1287,7 +1287,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_adjacent_folds(cx: &mut gpui::MutableAppContext) {
|
fn test_adjacent_folds(cx: &mut gpui::AppContext) {
|
||||||
cx.set_global(Settings::test(cx));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple("abcdefghijkl", cx);
|
let buffer = MultiBuffer::build_simple("abcdefghijkl", cx);
|
||||||
let subscription = buffer.update(cx, |buffer, _| buffer.subscribe());
|
let subscription = buffer.update(cx, |buffer, _| buffer.subscribe());
|
||||||
@ -1334,7 +1334,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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 = MultiBuffer::build_simple(&sample_text(5, 6, 'a'), cx);
|
||||||
let buffer_snapshot = buffer.read(cx).snapshot(cx);
|
let buffer_snapshot = buffer.read(cx).snapshot(cx);
|
||||||
let mut map = FoldMap::new(buffer_snapshot.clone()).0;
|
let mut map = FoldMap::new(buffer_snapshot.clone()).0;
|
||||||
@ -1350,7 +1350,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple(&sample_text(5, 6, 'a'), cx);
|
let buffer = MultiBuffer::build_simple(&sample_text(5, 6, 'a'), cx);
|
||||||
let subscription = buffer.update(cx, |buffer, _| buffer.subscribe());
|
let subscription = buffer.update(cx, |buffer, _| buffer.subscribe());
|
||||||
@ -1374,7 +1374,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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 = MultiBuffer::build_simple(&sample_text(5, 6, 'a'), cx);
|
||||||
let buffer_snapshot = buffer.read(cx).snapshot(cx);
|
let buffer_snapshot = buffer.read(cx).snapshot(cx);
|
||||||
let mut map = FoldMap::new(buffer_snapshot.clone()).0;
|
let mut map = FoldMap::new(buffer_snapshot.clone()).0;
|
||||||
@ -1401,7 +1401,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test(iterations = 100)]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
let operations = env::var("OPERATIONS")
|
let operations = env::var("OPERATIONS")
|
||||||
.map(|i| i.parse().expect("invalid `OPERATIONS` variable"))
|
.map(|i| i.parse().expect("invalid `OPERATIONS` variable"))
|
||||||
@ -1656,7 +1656,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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 text = sample_text(6, 6, 'a') + "\n";
|
||||||
let buffer = MultiBuffer::build_simple(&text, cx);
|
let buffer = MultiBuffer::build_simple(&text, cx);
|
||||||
|
|
||||||
|
@ -578,7 +578,7 @@ impl<'a> Iterator for SuggestionBufferRows<'a> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{display_map::fold_map::FoldMap, MultiBuffer};
|
use crate::{display_map::fold_map::FoldMap, MultiBuffer};
|
||||||
use gpui::MutableAppContext;
|
use gpui::AppContext;
|
||||||
use rand::{prelude::StdRng, Rng};
|
use rand::{prelude::StdRng, Rng};
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use std::{
|
use std::{
|
||||||
@ -587,7 +587,7 @@ mod tests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_basic(cx: &mut MutableAppContext) {
|
fn test_basic(cx: &mut AppContext) {
|
||||||
let buffer = MultiBuffer::build_simple("abcdefghi", cx);
|
let buffer = MultiBuffer::build_simple("abcdefghi", cx);
|
||||||
let buffer_edits = buffer.update(cx, |buffer, _| buffer.subscribe());
|
let buffer_edits = buffer.update(cx, |buffer, _| buffer.subscribe());
|
||||||
let (mut fold_map, fold_snapshot) = FoldMap::new(buffer.read(cx).snapshot(cx));
|
let (mut fold_map, fold_snapshot) = FoldMap::new(buffer.read(cx).snapshot(cx));
|
||||||
@ -632,7 +632,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test(iterations = 100)]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
let operations = env::var("OPERATIONS")
|
let operations = env::var("OPERATIONS")
|
||||||
.map(|i| i.parse().expect("invalid `OPERATIONS` variable"))
|
.map(|i| i.parse().expect("invalid `OPERATIONS` variable"))
|
||||||
|
@ -578,7 +578,7 @@ mod tests {
|
|||||||
use rand::{prelude::StdRng, Rng};
|
use rand::{prelude::StdRng, Rng};
|
||||||
|
|
||||||
#[gpui::test]
|
#[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 = MultiBuffer::build_simple("", cx);
|
||||||
let buffer_snapshot = buffer.read(cx).snapshot(cx);
|
let buffer_snapshot = buffer.read(cx).snapshot(cx);
|
||||||
let (_, fold_snapshot) = FoldMap::new(buffer_snapshot.clone());
|
let (_, fold_snapshot) = FoldMap::new(buffer_snapshot.clone());
|
||||||
@ -591,7 +591,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_long_lines(cx: &mut gpui::MutableAppContext) {
|
fn test_long_lines(cx: &mut gpui::AppContext) {
|
||||||
let max_expansion_column = 12;
|
let max_expansion_column = 12;
|
||||||
let input = "A\tBC\tDEF\tG\tHI\tJ\tK\tL\tM";
|
let input = "A\tBC\tDEF\tG\tHI\tJ\tK\tL\tM";
|
||||||
let output = "A BC DEF G HI J K L M";
|
let output = "A BC DEF G HI J K L M";
|
||||||
@ -641,7 +641,7 @@ mod tests {
|
|||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_long_lines_with_character_spanning_max_expansion_column(
|
fn test_long_lines_with_character_spanning_max_expansion_column(
|
||||||
cx: &mut gpui::MutableAppContext,
|
cx: &mut gpui::AppContext,
|
||||||
) {
|
) {
|
||||||
let max_expansion_column = 8;
|
let max_expansion_column = 8;
|
||||||
let input = "abcdefg⋯hij";
|
let input = "abcdefg⋯hij";
|
||||||
@ -657,7 +657,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test(iterations = 100)]
|
#[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 tab_size = NonZeroU32::new(rng.gen_range(1..=4)).unwrap();
|
||||||
let len = rng.gen_range(0..30);
|
let len = rng.gen_range(0..30);
|
||||||
let buffer = if rng.gen() {
|
let buffer = if rng.gen() {
|
||||||
|
@ -7,7 +7,7 @@ use crate::MultiBufferSnapshot;
|
|||||||
use gpui::{
|
use gpui::{
|
||||||
fonts::{FontId, HighlightStyle},
|
fonts::{FontId, HighlightStyle},
|
||||||
text_layout::LineWrapper,
|
text_layout::LineWrapper,
|
||||||
Entity, ModelContext, ModelHandle, MutableAppContext, Task,
|
AppContext, Entity, ModelContext, ModelHandle, Task,
|
||||||
};
|
};
|
||||||
use language::{Chunk, Point};
|
use language::{Chunk, Point};
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
@ -79,7 +79,7 @@ impl WrapMap {
|
|||||||
font_id: FontId,
|
font_id: FontId,
|
||||||
font_size: f32,
|
font_size: f32,
|
||||||
wrap_width: Option<f32>,
|
wrap_width: Option<f32>,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
) -> (ModelHandle<Self>, WrapSnapshot) {
|
) -> (ModelHandle<Self>, WrapSnapshot) {
|
||||||
let handle = cx.add_model(|cx| {
|
let handle = cx.add_model(|cx| {
|
||||||
let mut this = Self {
|
let mut this = Self {
|
||||||
|
@ -42,8 +42,8 @@ use gpui::{
|
|||||||
platform::CursorStyle,
|
platform::CursorStyle,
|
||||||
serde_json::{self, json},
|
serde_json::{self, json},
|
||||||
AnyViewHandle, AppContext, AsyncAppContext, ClipboardItem, Element, ElementBox, Entity,
|
AnyViewHandle, AppContext, AsyncAppContext, ClipboardItem, Element, ElementBox, Entity,
|
||||||
ModelHandle, MouseButton, MutableAppContext, RenderContext, Subscription, Task, View,
|
ModelHandle, MouseButton, RenderContext, Subscription, Task, View, ViewContext, ViewHandle,
|
||||||
ViewContext, ViewHandle, WeakViewHandle,
|
WeakViewHandle,
|
||||||
};
|
};
|
||||||
use highlight_matching_bracket::refresh_matching_bracket_highlights;
|
use highlight_matching_bracket::refresh_matching_bracket_highlights;
|
||||||
use hover_popover::{hide_hover, HideHover, HoverState};
|
use hover_popover::{hide_hover, HideHover, HoverState};
|
||||||
@ -295,7 +295,7 @@ pub enum Direction {
|
|||||||
Next,
|
Next,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
cx.add_action(Editor::new_file);
|
cx.add_action(Editor::new_file);
|
||||||
cx.add_action(Editor::select);
|
cx.add_action(Editor::select);
|
||||||
cx.add_action(Editor::cancel);
|
cx.add_action(Editor::cancel);
|
||||||
@ -1314,7 +1314,7 @@ impl Editor {
|
|||||||
self.buffer().read(cx).title(cx)
|
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 {
|
EditorSnapshot {
|
||||||
mode: self.mode,
|
mode: self.mode,
|
||||||
display_snapshot: self.display_map.update(cx, |map, cx| map.snapshot(cx)),
|
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
|
self.display_map
|
||||||
.update(cx, |map, cx| map.snapshot(cx))
|
.update(cx, |map, cx| map.snapshot(cx))
|
||||||
.longest_row()
|
.longest_row()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn max_point(&self, cx: &mut MutableAppContext) -> DisplayPoint {
|
pub fn max_point(&self, cx: &mut AppContext) -> DisplayPoint {
|
||||||
self.display_map
|
self.display_map
|
||||||
.update(cx, |map, cx| map.snapshot(cx))
|
.update(cx, |map, cx| map.snapshot(cx))
|
||||||
.max_point()
|
.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
|
self.display_map
|
||||||
.update(cx, |map, cx| map.snapshot(cx))
|
.update(cx, |map, cx| map.snapshot(cx))
|
||||||
.text()
|
.text()
|
||||||
@ -6226,7 +6226,7 @@ impl Editor {
|
|||||||
cx.notify();
|
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
|
self.display_map
|
||||||
.update(cx, |map, cx| map.set_wrap_width(width, cx))
|
.update(cx, |map, cx| map.set_wrap_width(width, cx))
|
||||||
}
|
}
|
||||||
@ -6766,7 +6766,7 @@ pub struct EditorReleased(pub WeakViewHandle<Editor>);
|
|||||||
impl Entity for Editor {
|
impl Entity for Editor {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
|
|
||||||
fn release(&mut self, cx: &mut MutableAppContext) {
|
fn release(&mut self, cx: &mut AppContext) {
|
||||||
cx.emit_global(EditorReleased(self.handle.clone()));
|
cx.emit_global(EditorReleased(self.handle.clone()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ use workspace::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_edit_events(cx: &mut MutableAppContext) {
|
fn test_edit_events(cx: &mut AppContext) {
|
||||||
cx.set_global(Settings::test(cx));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = cx.add_model(|cx| {
|
let buffer = cx.add_model(|cx| {
|
||||||
let mut buffer = language::Buffer::new(0, "123456", cx);
|
let mut buffer = language::Buffer::new(0, "123456", cx);
|
||||||
@ -155,7 +155,7 @@ fn test_edit_events(cx: &mut MutableAppContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
let mut now = Instant::now();
|
let mut now = Instant::now();
|
||||||
let buffer = cx.add_model(|cx| language::Buffer::new(0, "123456", cx));
|
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]
|
#[gpui::test]
|
||||||
fn test_ime_composition(cx: &mut MutableAppContext) {
|
fn test_ime_composition(cx: &mut AppContext) {
|
||||||
cx.set_global(Settings::test(cx));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = cx.add_model(|cx| {
|
let buffer = cx.add_model(|cx| {
|
||||||
let mut buffer = language::Buffer::new(0, "abcde", cx);
|
let mut buffer = language::Buffer::new(0, "abcde", cx);
|
||||||
@ -327,7 +327,7 @@ fn test_ime_composition(cx: &mut MutableAppContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
|
|
||||||
let buffer = MultiBuffer::build_simple("aaaaaa\nbbbbbb\ncccccc\nddddddd\n", 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]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple("aaaaaa\nbbbbbb\ncccccc\ndddddd\n", cx);
|
let buffer = MultiBuffer::build_simple("aaaaaa\nbbbbbb\ncccccc\ndddddd\n", cx);
|
||||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, 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]
|
#[gpui::test]
|
||||||
fn test_clone(cx: &mut gpui::MutableAppContext) {
|
fn test_clone(cx: &mut gpui::AppContext) {
|
||||||
let (text, selection_ranges) = marked_text_ranges(
|
let (text, selection_ranges) = marked_text_ranges(
|
||||||
indoc! {"
|
indoc! {"
|
||||||
one
|
one
|
||||||
@ -480,7 +480,7 @@ fn test_clone(cx: &mut gpui::MutableAppContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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(Settings::test(cx));
|
||||||
cx.set_global(DragAndDrop::<Workspace>::default());
|
cx.set_global(DragAndDrop::<Workspace>::default());
|
||||||
use workspace::item::Item;
|
use workspace::item::Item;
|
||||||
@ -492,7 +492,7 @@ fn test_navigation_history(cx: &mut gpui::MutableAppContext) {
|
|||||||
let handle = cx.handle();
|
let handle = cx.handle();
|
||||||
editor.set_nav_history(Some(pane.read(cx).nav_history_for_item(&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)
|
editor.nav_history.as_mut().unwrap().pop_backward(cx)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -590,7 +590,7 @@ fn test_navigation_history(cx: &mut gpui::MutableAppContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_cancel(cx: &mut gpui::MutableAppContext) {
|
fn test_cancel(cx: &mut gpui::AppContext) {
|
||||||
cx.set_global(Settings::test(cx));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple("aaaaaa\nbbbbbb\ncccccc\ndddddd\n", cx);
|
let buffer = MultiBuffer::build_simple("aaaaaa\nbbbbbb\ncccccc\ndddddd\n", cx);
|
||||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, 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]
|
#[gpui::test]
|
||||||
fn test_fold_action(cx: &mut gpui::MutableAppContext) {
|
fn test_fold_action(cx: &mut gpui::AppContext) {
|
||||||
cx.set_global(Settings::test(cx));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple(
|
let buffer = MultiBuffer::build_simple(
|
||||||
&"
|
&"
|
||||||
@ -717,7 +717,7 @@ fn test_fold_action(cx: &mut gpui::MutableAppContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_move_cursor(cx: &mut gpui::MutableAppContext) {
|
fn test_move_cursor(cx: &mut gpui::AppContext) {
|
||||||
cx.set_global(Settings::test(cx));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple(&sample_text(6, 6, 'a'), 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));
|
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]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple("ⓐⓑⓒⓓⓔ\nabcde\nαβγδε\n", cx);
|
let buffer = MultiBuffer::build_simple("ⓐⓑⓒⓓⓔ\nabcde\nαβγδε\n", cx);
|
||||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer.clone(), 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]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple("ⓐⓑⓒⓓⓔ\nabcd\nαβγ\nabcd\nⓐⓑⓒⓓⓔ\n", 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));
|
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]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple("abc\n def", cx);
|
let buffer = MultiBuffer::build_simple("abc\n def", cx);
|
||||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, 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]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple("use std::str::{foo, bar}\n\n {baz.qux()}", 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));
|
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]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple("use one::{\n two::three::four::five\n};", 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));
|
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]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple("one two three four", cx);
|
let buffer = MultiBuffer::build_simple("one two three four", cx);
|
||||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer.clone(), 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]
|
#[gpui::test]
|
||||||
fn test_newline(cx: &mut gpui::MutableAppContext) {
|
fn test_newline(cx: &mut gpui::AppContext) {
|
||||||
cx.set_global(Settings::test(cx));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple("aaaa\n bbbb\n", cx);
|
let buffer = MultiBuffer::build_simple("aaaa\n bbbb\n", cx);
|
||||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer.clone(), 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]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple(
|
let buffer = MultiBuffer::build_simple(
|
||||||
"
|
"
|
||||||
@ -1517,7 +1517,7 @@ async fn test_newline_below(cx: &mut gpui::TestAppContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple("a( X ), b( Y ), c( Z )", cx);
|
let buffer = MultiBuffer::build_simple("a( X ), b( Y ), c( Z )", cx);
|
||||||
let (_, editor) = cx.add_window(Default::default(), |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]
|
#[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(
|
cx.set_global(
|
||||||
Settings::test(cx)
|
Settings::test(cx)
|
||||||
.with_language_defaults(
|
.with_language_defaults(
|
||||||
@ -2022,7 +2022,7 @@ async fn test_delete(cx: &mut gpui::TestAppContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_delete_line(cx: &mut gpui::MutableAppContext) {
|
fn test_delete_line(cx: &mut gpui::AppContext) {
|
||||||
cx.set_global(Settings::test(cx));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple("abc\ndef\nghi\n", cx);
|
let buffer = MultiBuffer::build_simple("abc\ndef\nghi\n", cx);
|
||||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, 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]
|
#[gpui::test]
|
||||||
fn test_duplicate_line(cx: &mut gpui::MutableAppContext) {
|
fn test_duplicate_line(cx: &mut gpui::AppContext) {
|
||||||
cx.set_global(Settings::test(cx));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple("abc\ndef\nghi\n", cx);
|
let buffer = MultiBuffer::build_simple("abc\ndef\nghi\n", cx);
|
||||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, 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]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple(&sample_text(10, 5, 'a'), cx);
|
let buffer = MultiBuffer::build_simple(&sample_text(10, 5, 'a'), cx);
|
||||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, 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]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple(&sample_text(10, 5, 'a'), cx);
|
let buffer = MultiBuffer::build_simple(&sample_text(10, 5, 'a'), cx);
|
||||||
let snapshot = buffer.read(cx).snapshot(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]
|
#[gpui::test]
|
||||||
fn test_transpose(cx: &mut gpui::MutableAppContext) {
|
fn test_transpose(cx: &mut gpui::AppContext) {
|
||||||
cx.set_global(Settings::test(cx));
|
cx.set_global(Settings::test(cx));
|
||||||
|
|
||||||
_ = cx
|
_ = cx
|
||||||
@ -2524,7 +2524,7 @@ async fn test_paste_multiline(cx: &mut gpui::TestAppContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_select_all(cx: &mut gpui::MutableAppContext) {
|
fn test_select_all(cx: &mut gpui::AppContext) {
|
||||||
cx.set_global(Settings::test(cx));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple("abc\nde\nfgh", cx);
|
let buffer = MultiBuffer::build_simple("abc\nde\nfgh", cx);
|
||||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, 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]
|
#[gpui::test]
|
||||||
fn test_select_line(cx: &mut gpui::MutableAppContext) {
|
fn test_select_line(cx: &mut gpui::AppContext) {
|
||||||
cx.set_global(Settings::test(cx));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple(&sample_text(6, 5, 'a'), cx);
|
let buffer = MultiBuffer::build_simple(&sample_text(6, 5, 'a'), cx);
|
||||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, 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]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple(&sample_text(9, 5, 'a'), cx);
|
let buffer = MultiBuffer::build_simple(&sample_text(9, 5, 'a'), cx);
|
||||||
let (_, view) = cx.add_window(Default::default(), |cx| build_editor(buffer, 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]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple("abc\ndefghi\n\njk\nlmno\n", 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));
|
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]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = cx.add_model(|cx| Buffer::new(0, sample_text(3, 4, 'a'), cx));
|
let buffer = cx.add_model(|cx| Buffer::new(0, sample_text(3, 4, 'a'), cx));
|
||||||
let multibuffer = cx.add_model(|cx| {
|
let multibuffer = cx.add_model(|cx| {
|
||||||
@ -4975,7 +4975,7 @@ fn test_editing_disjoint_excerpts(cx: &mut gpui::MutableAppContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
let markers = vec![('[', ']').into(), ('(', ')').into()];
|
let markers = vec![('[', ']').into(), ('(', ')').into()];
|
||||||
let (initial_text, mut excerpt_ranges) = marked_text_ranges_by(
|
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]
|
#[gpui::test]
|
||||||
fn test_refresh_selections(cx: &mut gpui::MutableAppContext) {
|
fn test_refresh_selections(cx: &mut gpui::AppContext) {
|
||||||
cx.set_global(Settings::test(cx));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = cx.add_model(|cx| Buffer::new(0, sample_text(3, 4, 'a'), cx));
|
let buffer = cx.add_model(|cx| Buffer::new(0, sample_text(3, 4, 'a'), cx));
|
||||||
let mut excerpt1_id = None;
|
let mut excerpt1_id = None;
|
||||||
@ -5134,7 +5134,7 @@ fn test_refresh_selections(cx: &mut gpui::MutableAppContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = cx.add_model(|cx| Buffer::new(0, sample_text(3, 4, 'a'), cx));
|
let buffer = cx.add_model(|cx| Buffer::new(0, sample_text(3, 4, 'a'), cx));
|
||||||
let mut excerpt1_id = None;
|
let mut excerpt1_id = None;
|
||||||
@ -5267,7 +5267,7 @@ async fn test_extra_newline_insertion(cx: &mut gpui::TestAppContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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);
|
let buffer = MultiBuffer::build_simple(&sample_text(16, 8, 'a'), cx);
|
||||||
|
|
||||||
cx.set_global(Settings::test(cx));
|
cx.set_global(Settings::test(cx));
|
||||||
|
@ -32,8 +32,8 @@ use gpui::{
|
|||||||
platform::CursorStyle,
|
platform::CursorStyle,
|
||||||
text_layout::{self, Line, RunStyle, TextLayoutCache},
|
text_layout::{self, Line, RunStyle, TextLayoutCache},
|
||||||
AppContext, Axis, Border, CursorRegion, Element, ElementBox, EventContext, LayoutContext,
|
AppContext, Axis, Border, CursorRegion, Element, ElementBox, EventContext, LayoutContext,
|
||||||
Modifiers, MouseButton, MouseButtonEvent, MouseMovedEvent, MouseRegion, MutableAppContext,
|
Modifiers, MouseButton, MouseButtonEvent, MouseMovedEvent, MouseRegion, PaintContext, Quad,
|
||||||
PaintContext, Quad, SceneBuilder, SizeConstraint, ViewContext, WeakViewHandle,
|
SceneBuilder, SizeConstraint, ViewContext, WeakViewHandle,
|
||||||
};
|
};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use json::json;
|
use json::json;
|
||||||
@ -103,14 +103,14 @@ impl EditorElement {
|
|||||||
self.view.upgrade(cx).unwrap().read(cx)
|
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
|
where
|
||||||
F: FnOnce(&mut Editor, &mut ViewContext<Editor>) -> T,
|
F: FnOnce(&mut Editor, &mut ViewContext<Editor>) -> T,
|
||||||
{
|
{
|
||||||
self.view.upgrade(cx).unwrap().update(cx, f)
|
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))
|
self.update_view(cx, |view, cx| view.snapshot(cx))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2522,7 +2522,7 @@ mod tests {
|
|||||||
use util::test::sample_text;
|
use util::test::sample_text;
|
||||||
|
|
||||||
#[gpui::test]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple(&sample_text(6, 6, 'a'), cx);
|
let buffer = MultiBuffer::build_simple(&sample_text(6, 6, 'a'), cx);
|
||||||
let (window_id, editor) = cx.add_window(Default::default(), |cx| {
|
let (window_id, editor) = cx.add_window(Default::default(), |cx| {
|
||||||
@ -2542,7 +2542,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer = MultiBuffer::build_simple("", cx);
|
let buffer = MultiBuffer::build_simple("", cx);
|
||||||
let (window_id, editor) = cx.add_window(Default::default(), |cx| {
|
let (window_id, editor) = cx.add_window(Default::default(), |cx| {
|
||||||
|
@ -4,7 +4,7 @@ use gpui::{
|
|||||||
elements::{Flex, MouseEventHandler, Padding, Text},
|
elements::{Flex, MouseEventHandler, Padding, Text},
|
||||||
impl_internal_actions,
|
impl_internal_actions,
|
||||||
platform::CursorStyle,
|
platform::CursorStyle,
|
||||||
Axis, Element, ElementBox, ModelHandle, MouseButton, MutableAppContext, RenderContext, Task,
|
AppContext, Axis, Element, ElementBox, ModelHandle, MouseButton, RenderContext, Task,
|
||||||
ViewContext,
|
ViewContext,
|
||||||
};
|
};
|
||||||
use language::{Bias, DiagnosticEntry, DiagnosticSeverity};
|
use language::{Bias, DiagnosticEntry, DiagnosticSeverity};
|
||||||
@ -36,7 +36,7 @@ pub struct HideHover;
|
|||||||
actions!(editor, [Hover]);
|
actions!(editor, [Hover]);
|
||||||
impl_internal_actions!(editor, [HoverAt, HideHover]);
|
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);
|
||||||
cx.add_action(hover_at);
|
cx.add_action(hover_at);
|
||||||
cx.add_action(hide_hover);
|
cx.add_action(hide_hover);
|
||||||
|
@ -7,8 +7,8 @@ use anyhow::{anyhow, Context, Result};
|
|||||||
use collections::HashSet;
|
use collections::HashSet;
|
||||||
use futures::future::try_join_all;
|
use futures::future::try_join_all;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
elements::*, geometry::vector::vec2f, AppContext, Entity, ModelHandle, MutableAppContext,
|
elements::*, geometry::vector::vec2f, AppContext, Entity, ModelHandle, RenderContext,
|
||||||
RenderContext, Subscription, Task, View, ViewContext, ViewHandle, WeakViewHandle,
|
Subscription, Task, View, ViewContext, ViewHandle, WeakViewHandle,
|
||||||
};
|
};
|
||||||
use language::{
|
use language::{
|
||||||
proto::serialize_anchor as serialize_text_anchor, Bias, Buffer, OffsetRangeExt, Point,
|
proto::serialize_anchor as serialize_text_anchor, Bias, Buffer, OffsetRangeExt, Point,
|
||||||
@ -48,7 +48,7 @@ impl FollowableItem for Editor {
|
|||||||
project: ModelHandle<Project>,
|
project: ModelHandle<Project>,
|
||||||
remote_id: ViewId,
|
remote_id: ViewId,
|
||||||
state: &mut Option<proto::view::Variant>,
|
state: &mut Option<proto::view::Variant>,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
) -> Option<Task<Result<ViewHandle<Self>>>> {
|
) -> Option<Task<Result<ViewHandle<Self>>>> {
|
||||||
let Some(proto::view::Variant::Editor(_)) = state else { return None };
|
let Some(proto::view::Variant::Editor(_)) = state else { return None };
|
||||||
let Some(proto::view::Variant::Editor(state)) = state.take() else { unreachable!() };
|
let Some(proto::view::Variant::Editor(state)) = state.take() else { unreachable!() };
|
||||||
@ -769,7 +769,7 @@ impl Item for Editor {
|
|||||||
buffer: ModelHandle<Buffer>,
|
buffer: ModelHandle<Buffer>,
|
||||||
workspace_id: WorkspaceId,
|
workspace_id: WorkspaceId,
|
||||||
item_id: ItemId,
|
item_id: ItemId,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
) {
|
) {
|
||||||
if let Some(file) = buffer.read(cx).file().and_then(|file| file.as_local()) {
|
if let Some(file) = buffer.read(cx).file().and_then(|file| file.as_local()) {
|
||||||
let path = file.abs_path(cx);
|
let path = file.abs_path(cx);
|
||||||
@ -1161,7 +1161,7 @@ fn path_for_file<'a>(
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use gpui::MutableAppContext;
|
use gpui::AppContext;
|
||||||
use std::{
|
use std::{
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
@ -1169,7 +1169,7 @@ mod tests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_path_for_file(cx: &mut MutableAppContext) {
|
fn test_path_for_file(cx: &mut AppContext) {
|
||||||
let file = TestFile {
|
let file = TestFile {
|
||||||
path: Path::new("").into(),
|
path: Path::new("").into(),
|
||||||
full_path: PathBuf::from(""),
|
full_path: PathBuf::from(""),
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use std::ops::Range;
|
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 language::{Bias, ToOffset};
|
||||||
use project::LocationLink;
|
use project::LocationLink;
|
||||||
use settings::Settings;
|
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(update_go_to_definition_link);
|
||||||
cx.add_action(go_to_fetched_definition);
|
cx.add_action(go_to_fetched_definition);
|
||||||
cx.add_action(go_to_fetched_type_definition);
|
cx.add_action(go_to_fetched_type_definition);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use context_menu::ContextMenuItem;
|
use context_menu::ContextMenuItem;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
elements::AnchorCorner, geometry::vector::Vector2F, impl_internal_actions, MutableAppContext,
|
elements::AnchorCorner, geometry::vector::Vector2F, impl_internal_actions, AppContext,
|
||||||
ViewContext,
|
ViewContext,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ pub struct DeployMouseContextMenu {
|
|||||||
|
|
||||||
impl_internal_actions!(editor, [DeployMouseContextMenu]);
|
impl_internal_actions!(editor, [DeployMouseContextMenu]);
|
||||||
|
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
cx.add_action(deploy_context_menu);
|
cx.add_action(deploy_context_menu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,9 +372,9 @@ mod tests {
|
|||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
|
|
||||||
#[gpui::test]
|
#[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));
|
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);
|
let (snapshot, display_points) = marked_display_snapshot(marked_text, cx);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
previous_word_start(&snapshot, display_points[1]),
|
previous_word_start(&snapshot, display_points[1]),
|
||||||
@ -399,9 +399,9 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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));
|
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);
|
let (snapshot, display_points) = marked_display_snapshot(marked_text, cx);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
previous_subword_start(&snapshot, display_points[1]),
|
previous_subword_start(&snapshot, display_points[1]),
|
||||||
@ -433,11 +433,11 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
fn assert(
|
fn assert(
|
||||||
marked_text: &str,
|
marked_text: &str,
|
||||||
cx: &mut gpui::MutableAppContext,
|
cx: &mut gpui::AppContext,
|
||||||
is_boundary: impl FnMut(char, char) -> bool,
|
is_boundary: impl FnMut(char, char) -> bool,
|
||||||
) {
|
) {
|
||||||
let (snapshot, display_points) = marked_display_snapshot(marked_text, cx);
|
let (snapshot, display_points) = marked_display_snapshot(marked_text, cx);
|
||||||
@ -465,9 +465,9 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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));
|
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);
|
let (snapshot, display_points) = marked_display_snapshot(marked_text, cx);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
next_word_end(&snapshot, display_points[0]),
|
next_word_end(&snapshot, display_points[0]),
|
||||||
@ -489,9 +489,9 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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));
|
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);
|
let (snapshot, display_points) = marked_display_snapshot(marked_text, cx);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
next_subword_end(&snapshot, display_points[0]),
|
next_subword_end(&snapshot, display_points[0]),
|
||||||
@ -522,11 +522,11 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_find_boundary(cx: &mut gpui::MutableAppContext) {
|
fn test_find_boundary(cx: &mut gpui::AppContext) {
|
||||||
cx.set_global(Settings::test(cx));
|
cx.set_global(Settings::test(cx));
|
||||||
fn assert(
|
fn assert(
|
||||||
marked_text: &str,
|
marked_text: &str,
|
||||||
cx: &mut gpui::MutableAppContext,
|
cx: &mut gpui::AppContext,
|
||||||
is_boundary: impl FnMut(char, char) -> bool,
|
is_boundary: impl FnMut(char, char) -> bool,
|
||||||
) {
|
) {
|
||||||
let (snapshot, display_points) = marked_display_snapshot(marked_text, cx);
|
let (snapshot, display_points) = marked_display_snapshot(marked_text, cx);
|
||||||
@ -554,9 +554,9 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_surrounding_word(cx: &mut gpui::MutableAppContext) {
|
fn test_surrounding_word(cx: &mut gpui::AppContext) {
|
||||||
cx.set_global(Settings::test(cx));
|
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);
|
let (snapshot, display_points) = marked_display_snapshot(marked_text, cx);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
surrounding_word(&snapshot, display_points[1]),
|
surrounding_word(&snapshot, display_points[1]),
|
||||||
@ -575,7 +575,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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));
|
cx.set_global(Settings::test(cx));
|
||||||
let family_id = cx
|
let family_id = cx
|
||||||
.font_cache()
|
.font_cache()
|
||||||
|
@ -1489,15 +1489,12 @@ impl MultiBuffer {
|
|||||||
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
impl MultiBuffer {
|
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));
|
let buffer = cx.add_model(|cx| Buffer::new(0, text, cx));
|
||||||
cx.add_model(|cx| Self::singleton(buffer, cx))
|
cx.add_model(|cx| Self::singleton(buffer, cx))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn build_random(
|
pub fn build_random(rng: &mut impl rand::Rng, cx: &mut gpui::AppContext) -> ModelHandle<Self> {
|
||||||
rng: &mut impl rand::Rng,
|
|
||||||
cx: &mut gpui::MutableAppContext,
|
|
||||||
) -> ModelHandle<Self> {
|
|
||||||
cx.add_model(|cx| {
|
cx.add_model(|cx| {
|
||||||
let mut multibuffer = MultiBuffer::new(0);
|
let mut multibuffer = MultiBuffer::new(0);
|
||||||
let mutation_count = rng.gen_range(1..=5);
|
let mutation_count = rng.gen_range(1..=5);
|
||||||
@ -3729,7 +3726,7 @@ where
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use gpui::{MutableAppContext, TestAppContext};
|
use gpui::{AppContext, TestAppContext};
|
||||||
use language::{Buffer, Rope};
|
use language::{Buffer, Rope};
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
@ -3739,7 +3736,7 @@ mod tests {
|
|||||||
use util::test::sample_text;
|
use util::test::sample_text;
|
||||||
|
|
||||||
#[gpui::test]
|
#[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 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));
|
let multibuffer = cx.add_model(|cx| MultiBuffer::singleton(buffer.clone(), cx));
|
||||||
|
|
||||||
@ -3766,7 +3763,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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 host_buffer = cx.add_model(|cx| Buffer::new(0, "a", cx));
|
||||||
let guest_buffer = cx.add_model(|cx| {
|
let guest_buffer = cx.add_model(|cx| {
|
||||||
let state = host_buffer.read(cx).to_proto();
|
let state = host_buffer.read(cx).to_proto();
|
||||||
@ -3797,7 +3794,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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_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 buffer_2 = cx.add_model(|cx| Buffer::new(0, sample_text(6, 6, 'g'), cx));
|
||||||
let multibuffer = cx.add_model(|_| MultiBuffer::new(0));
|
let multibuffer = cx.add_model(|_| MultiBuffer::new(0));
|
||||||
@ -4021,7 +4018,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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_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));
|
let buffer_2 = cx.add_model(|cx| Buffer::new(0, sample_text(10, 3, 'm'), cx));
|
||||||
|
|
||||||
@ -4098,7 +4095,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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 buffer = cx.add_model(|cx| Buffer::new(0, sample_text(20, 3, 'a'), cx));
|
||||||
let multibuffer = cx.add_model(|_| MultiBuffer::new(0));
|
let multibuffer = cx.add_model(|_| MultiBuffer::new(0));
|
||||||
let anchor_ranges = multibuffer.update(cx, |multibuffer, cx| {
|
let anchor_ranges = multibuffer.update(cx, |multibuffer, cx| {
|
||||||
@ -4172,7 +4169,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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 multibuffer = cx.add_model(|_| MultiBuffer::new(0));
|
||||||
|
|
||||||
let snapshot = multibuffer.read(cx).snapshot(cx);
|
let snapshot = multibuffer.read(cx).snapshot(cx);
|
||||||
@ -4182,7 +4179,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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 buffer = cx.add_model(|cx| Buffer::new(0, "abcd", cx));
|
||||||
let multibuffer = cx.add_model(|cx| MultiBuffer::singleton(buffer.clone(), cx));
|
let multibuffer = cx.add_model(|cx| MultiBuffer::singleton(buffer.clone(), cx));
|
||||||
let old_snapshot = multibuffer.read(cx).snapshot(cx);
|
let old_snapshot = multibuffer.read(cx).snapshot(cx);
|
||||||
@ -4202,7 +4199,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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_1 = cx.add_model(|cx| Buffer::new(0, "abcd", cx));
|
||||||
let buffer_2 = cx.add_model(|cx| Buffer::new(0, "efghi", cx));
|
let buffer_2 = cx.add_model(|cx| Buffer::new(0, "efghi", cx));
|
||||||
let multibuffer = cx.add_model(|cx| {
|
let multibuffer = cx.add_model(|cx| {
|
||||||
@ -4260,7 +4257,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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_1 = cx.add_model(|cx| Buffer::new(0, "abcd", cx));
|
||||||
let buffer_2 = cx.add_model(|cx| Buffer::new(0, "ABCDEFGHIJKLMNOP", cx));
|
let buffer_2 = cx.add_model(|cx| Buffer::new(0, "ABCDEFGHIJKLMNOP", cx));
|
||||||
let multibuffer = cx.add_model(|_| MultiBuffer::new(0));
|
let multibuffer = cx.add_model(|_| MultiBuffer::new(0));
|
||||||
@ -4563,7 +4560,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test(iterations = 100)]
|
#[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")
|
let operations = env::var("OPERATIONS")
|
||||||
.map(|i| i.parse().expect("invalid `OPERATIONS` variable"))
|
.map(|i| i.parse().expect("invalid `OPERATIONS` variable"))
|
||||||
.unwrap_or(10);
|
.unwrap_or(10);
|
||||||
@ -4980,7 +4977,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_history(cx: &mut MutableAppContext) {
|
fn test_history(cx: &mut AppContext) {
|
||||||
cx.set_global(Settings::test(cx));
|
cx.set_global(Settings::test(cx));
|
||||||
let buffer_1 = cx.add_model(|cx| Buffer::new(0, "1234", 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));
|
let buffer_2 = cx.add_model(|cx| Buffer::new(0, "5678", cx));
|
||||||
|
@ -9,7 +9,7 @@ use std::{
|
|||||||
|
|
||||||
use gpui::{
|
use gpui::{
|
||||||
geometry::vector::{vec2f, Vector2F},
|
geometry::vector::{vec2f, Vector2F},
|
||||||
Axis, MutableAppContext, Task, ViewContext,
|
Axis, AppContext, Task, ViewContext,
|
||||||
};
|
};
|
||||||
use language::{Bias, Point};
|
use language::{Bias, Point};
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
@ -369,7 +369,7 @@ impl Editor {
|
|||||||
/// Ordering::Equal => on screen
|
/// Ordering::Equal => on screen
|
||||||
/// Ordering::Less => above the screen
|
/// Ordering::Less => above the screen
|
||||||
/// Ordering::Greater => below 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 snapshot = self.display_map.update(cx, |map, cx| map.snapshot(cx));
|
||||||
let newest_head = self
|
let newest_head = self
|
||||||
.selections
|
.selections
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use gpui::{
|
use gpui::{
|
||||||
actions, geometry::vector::Vector2F, impl_internal_actions, Axis, MutableAppContext,
|
actions, geometry::vector::Vector2F, impl_internal_actions, Axis, AppContext,
|
||||||
ViewContext,
|
ViewContext,
|
||||||
};
|
};
|
||||||
use language::Bias;
|
use language::Bias;
|
||||||
@ -32,7 +32,7 @@ pub struct Scroll {
|
|||||||
|
|
||||||
impl_internal_actions!(editor, [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::next_screen);
|
||||||
cx.add_action(Editor::scroll);
|
cx.add_action(Editor::scroll);
|
||||||
cx.add_action(Editor::scroll_cursor_top);
|
cx.add_action(Editor::scroll_cursor_top);
|
||||||
|
@ -6,7 +6,7 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use gpui::{AppContext, ModelHandle, MutableAppContext};
|
use gpui::{AppContext, ModelHandle};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use language::{Bias, Point, Selection, SelectionGoal, TextDimension, ToPoint};
|
use language::{Bias, Point, Selection, SelectionGoal, TextDimension, ToPoint};
|
||||||
use util::post_inc;
|
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))
|
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
|
// 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);
|
let mut selections = self.all::<Point>(cx);
|
||||||
if self.line_mode {
|
if self.line_mode {
|
||||||
let map = self.display_map(cx);
|
let map = self.display_map(cx);
|
||||||
@ -151,7 +151,7 @@ impl SelectionsCollection {
|
|||||||
|
|
||||||
pub fn all_adjusted_display(
|
pub fn all_adjusted_display(
|
||||||
&self,
|
&self,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
) -> (DisplaySnapshot, Vec<Selection<DisplayPoint>>) {
|
) -> (DisplaySnapshot, Vec<Selection<DisplayPoint>>) {
|
||||||
if self.line_mode {
|
if self.line_mode {
|
||||||
let selections = self.all::<Point>(cx);
|
let selections = self.all::<Point>(cx);
|
||||||
@ -198,7 +198,7 @@ impl SelectionsCollection {
|
|||||||
|
|
||||||
pub fn all_display(
|
pub fn all_display(
|
||||||
&self,
|
&self,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
) -> (DisplaySnapshot, Vec<Selection<DisplayPoint>>) {
|
) -> (DisplaySnapshot, Vec<Selection<DisplayPoint>>) {
|
||||||
let display_map = self.display_map(cx);
|
let display_map = self.display_map(cx);
|
||||||
let selections = self
|
let selections = self
|
||||||
@ -224,7 +224,7 @@ impl SelectionsCollection {
|
|||||||
resolve(self.newest_anchor(), &self.buffer(cx))
|
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 display_map = self.display_map(cx);
|
||||||
let selection = self
|
let selection = self
|
||||||
.newest_anchor()
|
.newest_anchor()
|
||||||
@ -279,7 +279,7 @@ impl SelectionsCollection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[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);
|
let display_map = self.display_map(cx);
|
||||||
self.disjoint_anchors()
|
self.disjoint_anchors()
|
||||||
.iter()
|
.iter()
|
||||||
@ -324,7 +324,7 @@ impl SelectionsCollection {
|
|||||||
|
|
||||||
pub(crate) fn change_with<R>(
|
pub(crate) fn change_with<R>(
|
||||||
&mut self,
|
&mut self,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
change: impl FnOnce(&mut MutableSelectionsCollection) -> R,
|
change: impl FnOnce(&mut MutableSelectionsCollection) -> R,
|
||||||
) -> (bool, R) {
|
) -> (bool, R) {
|
||||||
let mut mutable_collection = MutableSelectionsCollection {
|
let mut mutable_collection = MutableSelectionsCollection {
|
||||||
@ -345,7 +345,7 @@ impl SelectionsCollection {
|
|||||||
pub struct MutableSelectionsCollection<'a> {
|
pub struct MutableSelectionsCollection<'a> {
|
||||||
collection: &'a mut SelectionsCollection,
|
collection: &'a mut SelectionsCollection,
|
||||||
selections_changed: bool,
|
selections_changed: bool,
|
||||||
cx: &'a mut MutableAppContext,
|
cx: &'a mut AppContext,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> MutableSelectionsCollection<'a> {
|
impl<'a> MutableSelectionsCollection<'a> {
|
||||||
|
@ -21,7 +21,7 @@ fn init_logger() {
|
|||||||
// Returns a snapshot from text containing '|' character markers with the markers removed, and DisplayPoints for each one.
|
// Returns a snapshot from text containing '|' character markers with the markers removed, and DisplayPoints for each one.
|
||||||
pub fn marked_display_snapshot(
|
pub fn marked_display_snapshot(
|
||||||
text: &str,
|
text: &str,
|
||||||
cx: &mut gpui::MutableAppContext,
|
cx: &mut gpui::AppContext,
|
||||||
) -> (DisplaySnapshot, Vec<DisplayPoint>) {
|
) -> (DisplaySnapshot, Vec<DisplayPoint>) {
|
||||||
let (unmarked_text, markers) = marked_text_offsets(text);
|
let (unmarked_text, markers) = marked_text_offsets(text);
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ pub mod submit_feedback_button;
|
|||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
mod system_specs;
|
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 serde::Deserialize;
|
||||||
use system_specs::SystemSpecs;
|
use system_specs::SystemSpecs;
|
||||||
use workspace::{AppState, Workspace};
|
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 = SystemSpecs::new(&cx);
|
||||||
let system_specs_text = system_specs.to_string();
|
let system_specs_text = system_specs.to_string();
|
||||||
|
|
||||||
|
@ -11,8 +11,8 @@ use futures::AsyncReadExt;
|
|||||||
use gpui::{
|
use gpui::{
|
||||||
actions,
|
actions,
|
||||||
elements::{ChildView, Flex, Label, ParentElement, Svg},
|
elements::{ChildView, Flex, Label, ParentElement, Svg},
|
||||||
serde_json, AnyViewHandle, AppContext, Element, ElementBox, Entity, ModelHandle,
|
serde_json, AnyViewHandle, AppContext, Element, ElementBox, Entity, ModelHandle, PromptLevel,
|
||||||
MutableAppContext, PromptLevel, RenderContext, Task, View, ViewContext, ViewHandle,
|
RenderContext, Task, View, ViewContext, ViewHandle,
|
||||||
};
|
};
|
||||||
use isahc::Request;
|
use isahc::Request;
|
||||||
use language::Buffer;
|
use language::Buffer;
|
||||||
@ -35,7 +35,7 @@ const FEEDBACK_SUBMISSION_ERROR_TEXT: &str =
|
|||||||
|
|
||||||
actions!(feedback, [GiveFeedback, SubmitFeedback]);
|
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({
|
cx.add_action({
|
||||||
move |workspace: &mut Workspace, _: &GiveFeedback, cx: &mut ViewContext<Workspace>| {
|
move |workspace: &mut Workspace, _: &GiveFeedback, cx: &mut ViewContext<Workspace>| {
|
||||||
FeedbackEditor::deploy(system_specs.clone(), workspace, app_state.clone(), cx);
|
FeedbackEditor::deploy(system_specs.clone(), workspace, app_state.clone(), cx);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use fuzzy::PathMatch;
|
use fuzzy::PathMatch;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, elements::*, AnyViewHandle, AppContext, Entity, ModelHandle, MouseState,
|
actions, elements::*, AnyViewHandle, AppContext, Entity, ModelHandle, MouseState,
|
||||||
MutableAppContext, RenderContext, Task, View, ViewContext, ViewHandle,
|
RenderContext, Task, View, ViewContext, ViewHandle,
|
||||||
};
|
};
|
||||||
use picker::{Picker, PickerDelegate};
|
use picker::{Picker, PickerDelegate};
|
||||||
use project::{PathMatchCandidateSet, Project, ProjectPath, WorktreeId};
|
use project::{PathMatchCandidateSet, Project, ProjectPath, WorktreeId};
|
||||||
@ -31,7 +31,7 @@ pub struct FileFinder {
|
|||||||
|
|
||||||
actions!(file_finder, [Toggle]);
|
actions!(file_finder, [Toggle]);
|
||||||
|
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
cx.add_action(FileFinder::toggle);
|
cx.add_action(FileFinder::toggle);
|
||||||
Picker::<FileFinder>::init(cx);
|
Picker::<FileFinder>::init(cx);
|
||||||
}
|
}
|
||||||
|
@ -2,8 +2,8 @@ use std::sync::Arc;
|
|||||||
|
|
||||||
use editor::{display_map::ToDisplayPoint, scroll::autoscroll::Autoscroll, DisplayPoint, Editor};
|
use editor::{display_map::ToDisplayPoint, scroll::autoscroll::Autoscroll, DisplayPoint, Editor};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, elements::*, geometry::vector::Vector2F, AnyViewHandle, Axis, Entity,
|
actions, elements::*, geometry::vector::Vector2F, AnyViewHandle, AppContext, Axis, Entity,
|
||||||
MutableAppContext, RenderContext, View, ViewContext, ViewHandle,
|
RenderContext, View, ViewContext, ViewHandle,
|
||||||
};
|
};
|
||||||
use menu::{Cancel, Confirm};
|
use menu::{Cancel, Confirm};
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
@ -12,7 +12,7 @@ use workspace::Workspace;
|
|||||||
|
|
||||||
actions!(go_to_line, [Toggle]);
|
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::toggle);
|
||||||
cx.add_action(GoToLine::confirm);
|
cx.add_action(GoToLine::confirm);
|
||||||
cx.add_action(GoToLine::cancel);
|
cx.add_action(GoToLine::cancel);
|
||||||
@ -140,7 +140,7 @@ impl GoToLine {
|
|||||||
impl Entity for GoToLine {
|
impl Entity for GoToLine {
|
||||||
type Event = Event;
|
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();
|
let scroll_position = self.prev_scroll_position.take();
|
||||||
self.active_editor.update(cx, |editor, cx| {
|
self.active_editor.update(cx, |editor, cx| {
|
||||||
editor.highlight_rows(None);
|
editor.highlight_rows(None);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
|||||||
use crate::MutableAppContext;
|
use crate::AppContext;
|
||||||
use collections::{BTreeMap, HashMap, HashSet};
|
use collections::{BTreeMap, HashMap, HashSet};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
@ -93,10 +93,10 @@ impl<K: Clone + Hash + Eq + Copy, F> CallbackCollection<K, F> {
|
|||||||
drop(callbacks);
|
drop(callbacks);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn emit<C: FnMut(&mut F, &mut MutableAppContext) -> bool>(
|
pub fn emit<C: FnMut(&mut F, &mut AppContext) -> bool>(
|
||||||
&mut self,
|
&mut self,
|
||||||
key: K,
|
key: K,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
mut call_callback: C,
|
mut call_callback: C,
|
||||||
) {
|
) {
|
||||||
let callbacks = self.internal.lock().callbacks.remove(&key);
|
let callbacks = self.internal.lock().callbacks.remove(&key);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use crate::{Action, App, ForegroundPlatform, MutableAppContext};
|
use crate::{Action, App, AppContext, ForegroundPlatform};
|
||||||
|
|
||||||
pub struct Menu<'a> {
|
pub struct Menu<'a> {
|
||||||
pub name: &'a str,
|
pub name: &'a str,
|
||||||
@ -51,7 +51,7 @@ pub enum OsAction {
|
|||||||
Redo,
|
Redo,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MutableAppContext {
|
impl AppContext {
|
||||||
pub fn set_menus(&mut self, menus: Vec<Menu>) {
|
pub fn set_menus(&mut self, menus: Vec<Menu>) {
|
||||||
self.foreground_platform
|
self.foreground_platform
|
||||||
.set_menus(menus, &self.keystroke_matcher);
|
.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();
|
let cx = app.0.clone();
|
||||||
move |action| {
|
move |action| {
|
||||||
let mut cx = cx.borrow_mut();
|
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) {
|
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);
|
cx.handle_dispatch_action_from_effect(main_window_id, Some(view_id), action);
|
||||||
return;
|
return;
|
||||||
|
@ -19,9 +19,8 @@ use smol::stream::StreamExt;
|
|||||||
use crate::{
|
use crate::{
|
||||||
executor, geometry::vector::Vector2F, keymap_matcher::Keystroke, platform, Action,
|
executor, geometry::vector::Vector2F, keymap_matcher::Keystroke, platform, Action,
|
||||||
AnyViewHandle, AppContext, Appearance, Entity, Event, FontCache, Handle, InputHandler,
|
AnyViewHandle, AppContext, Appearance, Entity, Event, FontCache, Handle, InputHandler,
|
||||||
KeyDownEvent, ModelContext, ModelHandle, MutableAppContext, Platform, ReadModelWith,
|
KeyDownEvent, ModelContext, ModelHandle, Platform, ReadModelWith, ReadViewWith, RenderContext,
|
||||||
ReadViewWith, RenderContext, Task, UpdateModel, UpdateView, View, ViewContext, ViewHandle,
|
Task, UpdateModel, UpdateView, View, ViewContext, ViewHandle, WeakHandle,
|
||||||
WeakHandle,
|
|
||||||
};
|
};
|
||||||
use collections::BTreeMap;
|
use collections::BTreeMap;
|
||||||
|
|
||||||
@ -30,7 +29,7 @@ use super::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
pub struct TestAppContext {
|
pub struct TestAppContext {
|
||||||
cx: Rc<RefCell<MutableAppContext>>,
|
cx: Rc<RefCell<AppContext>>,
|
||||||
foreground_platform: Rc<platform::test::ForegroundPlatform>,
|
foreground_platform: Rc<platform::test::ForegroundPlatform>,
|
||||||
condition_duration: Option<Duration>,
|
condition_duration: Option<Duration>,
|
||||||
pub function_name: String,
|
pub function_name: String,
|
||||||
@ -48,7 +47,7 @@ impl TestAppContext {
|
|||||||
first_entity_id: usize,
|
first_entity_id: usize,
|
||||||
function_name: String,
|
function_name: String,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let mut cx = MutableAppContext::new(
|
let mut cx = AppContext::new(
|
||||||
foreground,
|
foreground,
|
||||||
background,
|
background,
|
||||||
platform,
|
platform,
|
||||||
@ -149,15 +148,15 @@ impl TestAppContext {
|
|||||||
self.cx.borrow().window_ids().collect()
|
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)
|
self.cx.borrow().root_view(window_id)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read<T, F: FnOnce(&AppContext) -> T>(&self, callback: F) -> T {
|
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();
|
let mut state = self.cx.borrow_mut();
|
||||||
// Don't increment pending flushes in order for effects to be flushed before the callback
|
// Don't increment pending flushes in order for effects to be flushed before the callback
|
||||||
// completes, which is helpful in tests.
|
// completes, which is helpful in tests.
|
||||||
@ -194,7 +193,7 @@ impl TestAppContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn font_cache(&self) -> Arc<FontCache> {
|
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> {
|
pub fn foreground_platform(&self) -> Rc<platform::test::ForegroundPlatform> {
|
||||||
@ -202,7 +201,7 @@ impl TestAppContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn platform(&self) -> Arc<dyn platform::Platform> {
|
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> {
|
pub fn foreground(&self) -> Rc<executor::Foreground> {
|
||||||
@ -396,7 +395,7 @@ impl ReadModelWith for TestAppContext {
|
|||||||
read: &mut dyn FnMut(&E, &AppContext) -> T,
|
read: &mut dyn FnMut(&E, &AppContext) -> T,
|
||||||
) -> T {
|
) -> T {
|
||||||
let cx = self.cx.borrow();
|
let cx = self.cx.borrow();
|
||||||
let cx = cx.as_ref();
|
let cx = &*cx;
|
||||||
read(handle.read(cx), cx)
|
read(handle.read(cx), cx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -424,7 +423,7 @@ impl ReadViewWith for TestAppContext {
|
|||||||
V: View,
|
V: View,
|
||||||
{
|
{
|
||||||
let cx = self.cx.borrow();
|
let cx = self.cx.borrow();
|
||||||
let cx = cx.as_ref();
|
let cx = &*cx;
|
||||||
read(handle.read(cx), cx)
|
read(handle.read(cx), cx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -513,7 +512,7 @@ impl<T: Entity> ModelHandle<T> {
|
|||||||
loop {
|
loop {
|
||||||
{
|
{
|
||||||
let cx = cx.borrow();
|
let cx = cx.borrow();
|
||||||
let cx = cx.as_ref();
|
let cx = &*cx;
|
||||||
if predicate(
|
if predicate(
|
||||||
handle
|
handle
|
||||||
.upgrade(cx)
|
.upgrade(cx)
|
||||||
@ -600,7 +599,7 @@ impl<T: View> ViewHandle<T> {
|
|||||||
loop {
|
loop {
|
||||||
{
|
{
|
||||||
let cx = cx.borrow();
|
let cx = cx.borrow();
|
||||||
let cx = cx.as_ref();
|
let cx = &*cx;
|
||||||
if predicate(
|
if predicate(
|
||||||
handle
|
handle
|
||||||
.upgrade(cx)
|
.upgrade(cx)
|
||||||
|
@ -2,10 +2,10 @@ use std::{cell::RefCell, ops::Range, rc::Rc};
|
|||||||
|
|
||||||
use pathfinder_geometry::rect::RectF;
|
use pathfinder_geometry::rect::RectF;
|
||||||
|
|
||||||
use crate::{AnyView, AppContext, InputHandler, MutableAppContext};
|
use crate::{AnyView, AppContext, InputHandler};
|
||||||
|
|
||||||
pub struct WindowInputHandler {
|
pub struct WindowInputHandler {
|
||||||
pub app: Rc<RefCell<MutableAppContext>>,
|
pub app: Rc<RefCell<AppContext>>,
|
||||||
pub window_id: usize,
|
pub window_id: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -23,21 +23,21 @@ impl WindowInputHandler {
|
|||||||
let app = self.app.try_borrow().ok()?;
|
let app = self.app.try_borrow().ok()?;
|
||||||
|
|
||||||
let view_id = app.focused_view_id(self.window_id)?;
|
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);
|
let result = f(view.as_ref(), &app);
|
||||||
Some(result)
|
Some(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_focused_view<T, F>(&mut self, f: F) -> Option<T>
|
fn update_focused_view<T, F>(&mut self, f: F) -> Option<T>
|
||||||
where
|
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()?;
|
let mut app = self.app.try_borrow_mut().ok()?;
|
||||||
app.update(|app| {
|
app.update(|app| {
|
||||||
let view_id = app.focused_view_id(self.window_id)?;
|
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);
|
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)
|
Some(result)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -210,7 +210,7 @@ mod tests {
|
|||||||
use crate::fonts::{Properties as FontProperties, Weight};
|
use crate::fonts::{Properties as FontProperties, Weight};
|
||||||
|
|
||||||
#[crate::test(self)]
|
#[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(
|
let default_style = TextStyle::new(
|
||||||
"Menlo",
|
"Menlo",
|
||||||
12.,
|
12.,
|
||||||
|
@ -630,7 +630,7 @@ mod tests {
|
|||||||
use std::env;
|
use std::env;
|
||||||
|
|
||||||
#[crate::test(self)]
|
#[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 mut presenter = cx.build_presenter(0, 0., Default::default());
|
||||||
let (_, view) = cx.add_window(Default::default(), |_| TestView);
|
let (_, view) = cx.add_window(Default::default(), |_| TestView);
|
||||||
let constraint = SizeConstraint::new(vec2f(0., 0.), vec2f(100., 40.));
|
let constraint = SizeConstraint::new(vec2f(0., 0.), vec2f(100., 40.));
|
||||||
@ -725,7 +725,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[crate::test(self, iterations = 10, seed = 0)]
|
#[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")
|
let operations = env::var("OPERATIONS")
|
||||||
.map(|i| i.parse().expect("invalid `OPERATIONS` variable"))
|
.map(|i| i.parse().expect("invalid `OPERATIONS` variable"))
|
||||||
.unwrap_or(10);
|
.unwrap_or(10);
|
||||||
|
@ -271,12 +271,10 @@ pub fn layout_highlighted_chunks<'a>(
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::{
|
use crate::{elements::Empty, fonts, AppContext, ElementBox, Entity, RenderContext, View};
|
||||||
elements::Empty, fonts, ElementBox, Entity, MutableAppContext, RenderContext, View,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[crate::test(self)]
|
#[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 (window_id, _) = cx.add_window(Default::default(), |_| TestView);
|
||||||
let mut presenter = cx.build_presenter(window_id, Default::default(), Default::default());
|
let mut presenter = cx.build_presenter(window_id, Default::default(), Default::default());
|
||||||
fonts::with_font_cache(cx.font_cache().clone(), || {
|
fonts::with_font_cache(cx.font_cache().clone(), || {
|
||||||
|
@ -17,7 +17,7 @@ use std::{
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
platform::{self, Dispatcher},
|
platform::{self, Dispatcher},
|
||||||
util, MutableAppContext,
|
util, AppContext,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub enum Foreground {
|
pub enum Foreground {
|
||||||
@ -931,7 +931,7 @@ impl<T> Task<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<T: 'static, E: 'static + Display> Task<Result<T, E>> {
|
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 {
|
cx.spawn(|_| async move {
|
||||||
if let Err(err) = self.await {
|
if let Err(err) = self.await {
|
||||||
log::error!("{}", err);
|
log::error!("{}", err);
|
||||||
|
@ -498,12 +498,12 @@ extern "C" {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::MutableAppContext;
|
use crate::AppContext;
|
||||||
use font_kit::properties::{Style, Weight};
|
use font_kit::properties::{Style, Weight};
|
||||||
use platform::FontSystem as _;
|
use platform::FontSystem as _;
|
||||||
|
|
||||||
#[crate::test(self, retries = 5)]
|
#[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
|
// This is failing intermittently on CI and we don't have time to figure it out
|
||||||
let fonts = FontSystem::new();
|
let fonts = FontSystem::new();
|
||||||
let menlo = fonts.load_family("Menlo", &Default::default()).unwrap();
|
let menlo = fonts.load_family("Menlo", &Default::default()).unwrap();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
app::{AppContext, MutableAppContext, WindowInvalidation},
|
app::WindowInvalidation,
|
||||||
elements::Element,
|
elements::Element,
|
||||||
font_cache::FontCache,
|
font_cache::FontCache,
|
||||||
geometry::rect::RectF,
|
geometry::rect::RectF,
|
||||||
@ -10,11 +10,11 @@ use crate::{
|
|||||||
MouseMove, MouseMoveOut, MouseScrollWheel, MouseUp, MouseUpOut, Scene,
|
MouseMove, MouseMoveOut, MouseScrollWheel, MouseUp, MouseUpOut, Scene,
|
||||||
},
|
},
|
||||||
text_layout::TextLayoutCache,
|
text_layout::TextLayoutCache,
|
||||||
Action, AnyModelHandle, AnyViewHandle, AnyWeakModelHandle, AnyWeakViewHandle, Appearance,
|
Action, AnyModelHandle, AnyViewHandle, AnyWeakModelHandle, AnyWeakViewHandle, AppContext,
|
||||||
AssetCache, ElementBox, Entity, FontSystem, ModelHandle, MouseButton, MouseMovedEvent,
|
Appearance, AssetCache, ElementBox, Entity, FontSystem, ModelHandle, MouseButton,
|
||||||
MouseRegion, MouseRegionId, MouseState, ParentId, ReadModel, ReadView, RenderContext,
|
MouseMovedEvent, MouseRegion, MouseRegionId, MouseState, ParentId, ReadModel, ReadView,
|
||||||
RenderParams, SceneBuilder, UpgradeModelHandle, UpgradeViewHandle, View, ViewHandle,
|
RenderContext, RenderParams, SceneBuilder, UpgradeModelHandle, UpgradeViewHandle, View,
|
||||||
WeakModelHandle, WeakViewHandle,
|
ViewHandle, WeakModelHandle, WeakViewHandle,
|
||||||
};
|
};
|
||||||
use anyhow::bail;
|
use anyhow::bail;
|
||||||
use collections::{HashMap, HashSet};
|
use collections::{HashMap, HashSet};
|
||||||
@ -56,7 +56,7 @@ impl Presenter {
|
|||||||
font_cache: Arc<FontCache>,
|
font_cache: Arc<FontCache>,
|
||||||
text_layout_cache: TextLayoutCache,
|
text_layout_cache: TextLayoutCache,
|
||||||
asset_cache: Arc<AssetCache>,
|
asset_cache: Arc<AssetCache>,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
window_id,
|
window_id,
|
||||||
@ -80,7 +80,7 @@ impl Presenter {
|
|||||||
&mut self,
|
&mut self,
|
||||||
invalidation: &mut WindowInvalidation,
|
invalidation: &mut WindowInvalidation,
|
||||||
appearance: Appearance,
|
appearance: Appearance,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
) {
|
) {
|
||||||
cx.start_frame();
|
cx.start_frame();
|
||||||
self.appearance = appearance;
|
self.appearance = appearance;
|
||||||
@ -111,7 +111,7 @@ impl Presenter {
|
|||||||
&mut self,
|
&mut self,
|
||||||
invalidation: &mut WindowInvalidation,
|
invalidation: &mut WindowInvalidation,
|
||||||
appearance: Appearance,
|
appearance: Appearance,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
) {
|
) {
|
||||||
self.invalidate(invalidation, appearance, cx);
|
self.invalidate(invalidation, appearance, cx);
|
||||||
for (view_id, view) in &mut self.rendered_views {
|
for (view_id, view) in &mut self.rendered_views {
|
||||||
@ -138,7 +138,7 @@ impl Presenter {
|
|||||||
window_size: Vector2F,
|
window_size: Vector2F,
|
||||||
scale_factor: f32,
|
scale_factor: f32,
|
||||||
refreshing: bool,
|
refreshing: bool,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
) -> Scene {
|
) -> Scene {
|
||||||
let mut scene_builder = SceneBuilder::new(scale_factor);
|
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) {
|
if let Some(root_view_id) = cx.root_view_id(self.window_id) {
|
||||||
self.build_layout_context(window_size, refreshing, cx)
|
self.build_layout_context(window_size, refreshing, cx)
|
||||||
.layout(root_view_id, SizeConstraint::strict(window_size));
|
.layout(root_view_id, SizeConstraint::strict(window_size));
|
||||||
@ -180,7 +180,7 @@ impl Presenter {
|
|||||||
&'a mut self,
|
&'a mut self,
|
||||||
window_size: Vector2F,
|
window_size: Vector2F,
|
||||||
refreshing: bool,
|
refreshing: bool,
|
||||||
cx: &'a mut MutableAppContext,
|
cx: &'a mut AppContext,
|
||||||
) -> LayoutContext<'a> {
|
) -> LayoutContext<'a> {
|
||||||
LayoutContext {
|
LayoutContext {
|
||||||
window_id: self.window_id,
|
window_id: self.window_id,
|
||||||
@ -206,7 +206,7 @@ impl Presenter {
|
|||||||
&'a mut self,
|
&'a mut self,
|
||||||
scene: &'a mut SceneBuilder,
|
scene: &'a mut SceneBuilder,
|
||||||
window_size: Vector2F,
|
window_size: Vector2F,
|
||||||
cx: &'a mut MutableAppContext,
|
cx: &'a mut AppContext,
|
||||||
) -> PaintContext {
|
) -> PaintContext {
|
||||||
PaintContext {
|
PaintContext {
|
||||||
scene,
|
scene,
|
||||||
@ -234,7 +234,7 @@ impl Presenter {
|
|||||||
&mut self,
|
&mut self,
|
||||||
event: Event,
|
event: Event,
|
||||||
event_reused: bool,
|
event_reused: bool,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
let mut mouse_events = SmallVec::<[_; 2]>::new();
|
let mut mouse_events = SmallVec::<[_; 2]>::new();
|
||||||
let mut notified_views: HashSet<usize> = Default::default();
|
let mut notified_views: HashSet<usize> = Default::default();
|
||||||
@ -557,7 +557,7 @@ impl Presenter {
|
|||||||
pub fn build_event_context<'a>(
|
pub fn build_event_context<'a>(
|
||||||
&'a mut self,
|
&'a mut self,
|
||||||
notified_views: &'a mut HashSet<usize>,
|
notified_views: &'a mut HashSet<usize>,
|
||||||
cx: &'a mut MutableAppContext,
|
cx: &'a mut AppContext,
|
||||||
) -> EventContext<'a> {
|
) -> EventContext<'a> {
|
||||||
EventContext {
|
EventContext {
|
||||||
font_cache: &self.font_cache,
|
font_cache: &self.font_cache,
|
||||||
@ -595,7 +595,7 @@ pub struct LayoutContext<'a> {
|
|||||||
pub font_system: Arc<dyn FontSystem>,
|
pub font_system: Arc<dyn FontSystem>,
|
||||||
pub text_layout_cache: &'a TextLayoutCache,
|
pub text_layout_cache: &'a TextLayoutCache,
|
||||||
pub asset_cache: &'a AssetCache,
|
pub asset_cache: &'a AssetCache,
|
||||||
pub app: &'a mut MutableAppContext,
|
pub app: &'a mut AppContext,
|
||||||
pub refreshing: bool,
|
pub refreshing: bool,
|
||||||
pub window_size: Vector2F,
|
pub window_size: Vector2F,
|
||||||
titlebar_height: f32,
|
titlebar_height: f32,
|
||||||
@ -692,7 +692,7 @@ impl<'a> LayoutContext<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Deref for LayoutContext<'a> {
|
impl<'a> Deref for LayoutContext<'a> {
|
||||||
type Target = MutableAppContext;
|
type Target = AppContext;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
self.app
|
self.app
|
||||||
@ -804,7 +804,7 @@ impl<'a> Deref for PaintContext<'a> {
|
|||||||
pub struct EventContext<'a> {
|
pub struct EventContext<'a> {
|
||||||
pub font_cache: &'a FontCache,
|
pub font_cache: &'a FontCache,
|
||||||
pub text_layout_cache: &'a TextLayoutCache,
|
pub text_layout_cache: &'a TextLayoutCache,
|
||||||
pub app: &'a mut MutableAppContext,
|
pub app: &'a mut AppContext,
|
||||||
pub window_id: usize,
|
pub window_id: usize,
|
||||||
pub notify_count: usize,
|
pub notify_count: usize,
|
||||||
view_stack: Vec<usize>,
|
view_stack: Vec<usize>,
|
||||||
@ -871,7 +871,7 @@ impl<'a> EventContext<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> Deref for EventContext<'a> {
|
impl<'a> Deref for EventContext<'a> {
|
||||||
type Target = MutableAppContext;
|
type Target = AppContext;
|
||||||
|
|
||||||
fn deref(&self) -> &Self::Target {
|
fn deref(&self) -> &Self::Target {
|
||||||
self.app
|
self.app
|
||||||
|
@ -18,7 +18,7 @@ use crate::{
|
|||||||
executor::{self, ExecutorEvent},
|
executor::{self, ExecutorEvent},
|
||||||
platform,
|
platform,
|
||||||
util::CwdBacktrace,
|
util::CwdBacktrace,
|
||||||
Element, ElementBox, Entity, FontCache, Handle, MutableAppContext, Platform, RenderContext,
|
AppContext, Element, ElementBox, Entity, FontCache, Handle, Platform, RenderContext,
|
||||||
Subscription, TestAppContext, View,
|
Subscription, TestAppContext, View,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ pub fn run_test(
|
|||||||
detect_nondeterminism: bool,
|
detect_nondeterminism: bool,
|
||||||
test_fn: &mut (dyn RefUnwindSafe
|
test_fn: &mut (dyn RefUnwindSafe
|
||||||
+ Fn(
|
+ Fn(
|
||||||
&mut MutableAppContext,
|
&mut AppContext,
|
||||||
Rc<platform::test::ForegroundPlatform>,
|
Rc<platform::test::ForegroundPlatform>,
|
||||||
Arc<executor::Deterministic>,
|
Arc<executor::Deterministic>,
|
||||||
u64,
|
u64,
|
||||||
|
@ -660,7 +660,7 @@ mod tests {
|
|||||||
use crate::fonts::{Properties, Weight};
|
use crate::fonts::{Properties, Weight};
|
||||||
|
|
||||||
#[crate::test(self)]
|
#[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_cache = cx.font_cache().clone();
|
||||||
let font_system = cx.platform().fonts();
|
let font_system = cx.platform().fonts();
|
||||||
let family = font_cache
|
let family = font_cache
|
||||||
@ -721,7 +721,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[crate::test(self, retries = 5)]
|
#[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
|
// 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_cache = cx.font_cache().clone();
|
||||||
let font_system = cx.platform().fonts();
|
let font_system = cx.platform().fonts();
|
||||||
|
@ -2,6 +2,6 @@ mod select;
|
|||||||
|
|
||||||
pub use select::{ItemType, Select, SelectStyle};
|
pub use select::{ItemType, Select, SelectStyle};
|
||||||
|
|
||||||
pub fn init(cx: &mut super::MutableAppContext) {
|
pub fn init(cx: &mut super::AppContext) {
|
||||||
select::init(cx);
|
select::init(cx);
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
actions, elements::*, impl_actions, AppContext, Entity, MouseButton, MutableAppContext,
|
actions, elements::*, impl_actions, AppContext, Entity, MouseButton, RenderContext, View,
|
||||||
RenderContext, View, ViewContext, WeakViewHandle,
|
ViewContext, WeakViewHandle,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Select {
|
pub struct Select {
|
||||||
@ -12,7 +12,7 @@ pub struct Select {
|
|||||||
item_count: usize,
|
item_count: usize,
|
||||||
is_open: bool,
|
is_open: bool,
|
||||||
list_state: UniformListState,
|
list_state: UniformListState,
|
||||||
build_style: Option<Box<dyn FnMut(&mut MutableAppContext) -> SelectStyle>>,
|
build_style: Option<Box<dyn FnMut(&mut AppContext) -> SelectStyle>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Default)]
|
#[derive(Clone, Default)]
|
||||||
@ -35,7 +35,7 @@ impl_actions!(select, [SelectItem]);
|
|||||||
|
|
||||||
pub enum Event {}
|
pub enum Event {}
|
||||||
|
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
cx.add_action(Select::toggle);
|
cx.add_action(Select::toggle);
|
||||||
cx.add_action(Select::select_item);
|
cx.add_action(Select::select_item);
|
||||||
}
|
}
|
||||||
@ -57,10 +57,7 @@ impl Select {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn with_style(
|
pub fn with_style(mut self, f: impl 'static + FnMut(&mut AppContext) -> SelectStyle) -> Self {
|
||||||
mut self,
|
|
||||||
f: impl 'static + FnMut(&mut MutableAppContext) -> SelectStyle,
|
|
||||||
) -> Self {
|
|
||||||
self.build_style = Some(Box::new(f));
|
self.build_style = Some(Box::new(f));
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use chrono::{Datelike, Local, NaiveTime, Timelike};
|
use chrono::{Datelike, Local, NaiveTime, Timelike};
|
||||||
use editor::{scroll::autoscroll::Autoscroll, Editor};
|
use editor::{scroll::autoscroll::Autoscroll, Editor};
|
||||||
use gpui::{actions, MutableAppContext};
|
use gpui::{actions, AppContext};
|
||||||
use settings::{HourFormat, Settings};
|
use settings::{HourFormat, Settings};
|
||||||
use std::{
|
use std::{
|
||||||
fs::OpenOptions,
|
fs::OpenOptions,
|
||||||
@ -12,11 +12,11 @@ use workspace::AppState;
|
|||||||
|
|
||||||
actions!(journal, [NewJournalEntry]);
|
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));
|
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 settings = cx.global::<Settings>();
|
||||||
let journal_dir = match journal_dir(&settings) {
|
let journal_dir = match journal_dir(&settings) {
|
||||||
Some(journal_dir) => journal_dir,
|
Some(journal_dir) => journal_dir,
|
||||||
|
@ -15,7 +15,7 @@ use anyhow::{anyhow, Result};
|
|||||||
use clock::ReplicaId;
|
use clock::ReplicaId;
|
||||||
use fs::LineEnding;
|
use fs::LineEnding;
|
||||||
use futures::FutureExt as _;
|
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 parking_lot::Mutex;
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
use similar::{ChangeTag, TextDiff};
|
use similar::{ChangeTag, TextDiff};
|
||||||
@ -232,7 +232,7 @@ pub trait LocalFile: File {
|
|||||||
fingerprint: RopeFingerprint,
|
fingerprint: RopeFingerprint,
|
||||||
line_ending: LineEnding,
|
line_ending: LineEnding,
|
||||||
mtime: SystemTime,
|
mtime: SystemTime,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ use super::*;
|
|||||||
use clock::ReplicaId;
|
use clock::ReplicaId;
|
||||||
use collections::BTreeMap;
|
use collections::BTreeMap;
|
||||||
use fs::LineEnding;
|
use fs::LineEnding;
|
||||||
use gpui::{ModelHandle, MutableAppContext};
|
use gpui::{AppContext, ModelHandle};
|
||||||
use indoc::indoc;
|
use indoc::indoc;
|
||||||
use proto::deserialize_operation;
|
use proto::deserialize_operation;
|
||||||
use rand::prelude::*;
|
use rand::prelude::*;
|
||||||
@ -35,7 +35,7 @@ fn init_logger() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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.set_global(Settings::test(cx));
|
||||||
cx.add_model(|cx| {
|
cx.add_model(|cx| {
|
||||||
let mut buffer =
|
let mut buffer =
|
||||||
@ -128,7 +128,7 @@ fn test_select_language() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_edit_events(cx: &mut gpui::MutableAppContext) {
|
fn test_edit_events(cx: &mut gpui::AppContext) {
|
||||||
let mut now = Instant::now();
|
let mut now = Instant::now();
|
||||||
let buffer_1_events = Rc::new(RefCell::new(Vec::new()));
|
let buffer_1_events = Rc::new(RefCell::new(Vec::new()));
|
||||||
let buffer_2_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]
|
#[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| {
|
let mut assert = |selection_text, range_markers| {
|
||||||
assert_bracket_pairs(selection_text, range_markers, rust_lang(), cx)
|
assert_bracket_pairs(selection_text, range_markers, rust_lang(), cx)
|
||||||
};
|
};
|
||||||
@ -791,9 +791,7 @@ fn test_enclosing_bracket_ranges(cx: &mut MutableAppContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_enclosing_bracket_ranges_where_brackets_are_not_outermost_children(
|
fn test_enclosing_bracket_ranges_where_brackets_are_not_outermost_children(cx: &mut AppContext) {
|
||||||
cx: &mut MutableAppContext,
|
|
||||||
) {
|
|
||||||
let mut assert = |selection_text, bracket_pair_texts| {
|
let mut assert = |selection_text, bracket_pair_texts| {
|
||||||
assert_bracket_pairs(selection_text, bracket_pair_texts, javascript_lang(), cx)
|
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]
|
#[gpui::test]
|
||||||
fn test_range_for_syntax_ancestor(cx: &mut MutableAppContext) {
|
fn test_range_for_syntax_ancestor(cx: &mut AppContext) {
|
||||||
cx.add_model(|cx| {
|
cx.add_model(|cx| {
|
||||||
let text = "fn a() { b(|c| {}) }";
|
let text = "fn a() { b(|c| {}) }";
|
||||||
let buffer = Buffer::new(0, text, cx).with_language(Arc::new(rust_lang()), cx);
|
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]
|
#[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);
|
let settings = Settings::test(cx);
|
||||||
cx.set_global(settings);
|
cx.set_global(settings);
|
||||||
|
|
||||||
@ -904,7 +902,7 @@ fn test_autoindent_with_soft_tabs(cx: &mut MutableAppContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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);
|
let mut settings = Settings::test(cx);
|
||||||
settings.editor_overrides.hard_tabs = Some(true);
|
settings.editor_overrides.hard_tabs = Some(true);
|
||||||
cx.set_global(settings);
|
cx.set_global(settings);
|
||||||
@ -946,7 +944,7 @@ fn test_autoindent_with_hard_tabs(cx: &mut MutableAppContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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);
|
let settings = Settings::test(cx);
|
||||||
cx.set_global(settings);
|
cx.set_global(settings);
|
||||||
|
|
||||||
@ -1083,7 +1081,7 @@ fn test_autoindent_does_not_adjust_lines_with_unchanged_suggestion(cx: &mut Muta
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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);
|
let settings = Settings::test(cx);
|
||||||
cx.set_global(settings);
|
cx.set_global(settings);
|
||||||
|
|
||||||
@ -1146,7 +1144,7 @@ fn test_autoindent_does_not_adjust_lines_within_newly_created_errors(cx: &mut Mu
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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.set_global(Settings::test(cx));
|
||||||
cx.add_model(|cx| {
|
cx.add_model(|cx| {
|
||||||
let mut buffer = Buffer::new(
|
let mut buffer = Buffer::new(
|
||||||
@ -1202,7 +1200,7 @@ fn test_autoindent_adjusts_lines_when_only_text_changes(cx: &mut MutableAppConte
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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.set_global(Settings::test(cx));
|
||||||
cx.add_model(|cx| {
|
cx.add_model(|cx| {
|
||||||
let text = "a\nb";
|
let text = "a\nb";
|
||||||
@ -1218,7 +1216,7 @@ fn test_autoindent_with_edit_at_end_of_buffer(cx: &mut MutableAppContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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.set_global(Settings::test(cx));
|
||||||
cx.add_model(|cx| {
|
cx.add_model(|cx| {
|
||||||
let text = "
|
let text = "
|
||||||
@ -1258,7 +1256,7 @@ fn test_autoindent_multi_line_insertion(cx: &mut MutableAppContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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.set_global(Settings::test(cx));
|
||||||
cx.add_model(|cx| {
|
cx.add_model(|cx| {
|
||||||
let text = r#"
|
let text = r#"
|
||||||
@ -1340,7 +1338,7 @@ fn test_autoindent_block_mode(cx: &mut MutableAppContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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.set_global(Settings::test(cx));
|
||||||
cx.add_model(|cx| {
|
cx.add_model(|cx| {
|
||||||
let text = r#"
|
let text = r#"
|
||||||
@ -1418,7 +1416,7 @@ fn test_autoindent_block_mode_without_original_indent_columns(cx: &mut MutableAp
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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.set_global(Settings::test(cx));
|
||||||
cx.add_model(|cx| {
|
cx.add_model(|cx| {
|
||||||
let text = "
|
let text = "
|
||||||
@ -1461,7 +1459,7 @@ fn test_autoindent_language_without_indents_query(cx: &mut MutableAppContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_autoindent_with_injected_languages(cx: &mut MutableAppContext) {
|
fn test_autoindent_with_injected_languages(cx: &mut AppContext) {
|
||||||
cx.set_global({
|
cx.set_global({
|
||||||
let mut settings = Settings::test(cx);
|
let mut settings = Settings::test(cx);
|
||||||
settings.language_overrides.extend([
|
settings.language_overrides.extend([
|
||||||
@ -1575,7 +1573,7 @@ fn test_autoindent_with_injected_languages(cx: &mut MutableAppContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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);
|
let mut settings = Settings::test(cx);
|
||||||
settings.editor_defaults.tab_size = Some(2.try_into().unwrap());
|
settings.editor_defaults.tab_size = Some(2.try_into().unwrap());
|
||||||
cx.set_global(settings);
|
cx.set_global(settings);
|
||||||
@ -1618,7 +1616,7 @@ fn test_autoindent_query_with_outdent_captures(cx: &mut MutableAppContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[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.set_global(Settings::test(cx));
|
||||||
cx.add_model(|cx| {
|
cx.add_model(|cx| {
|
||||||
let language = Language::new(
|
let language = Language::new(
|
||||||
@ -1705,7 +1703,7 @@ fn test_language_config_at(cx: &mut MutableAppContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test]
|
#[gpui::test]
|
||||||
fn test_serialization(cx: &mut gpui::MutableAppContext) {
|
fn test_serialization(cx: &mut gpui::AppContext) {
|
||||||
let mut now = Instant::now();
|
let mut now = Instant::now();
|
||||||
|
|
||||||
let buffer1 = cx.add_model(|cx| {
|
let buffer1 = cx.add_model(|cx| {
|
||||||
@ -1746,7 +1744,7 @@ fn test_serialization(cx: &mut gpui::MutableAppContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[gpui::test(iterations = 100)]
|
#[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")
|
let min_peers = env::var("MIN_PEERS")
|
||||||
.map(|i| i.parse().expect("invalid `MIN_PEERS` variable"))
|
.map(|i| i.parse().expect("invalid `MIN_PEERS` variable"))
|
||||||
.unwrap_or(1);
|
.unwrap_or(1);
|
||||||
@ -2199,7 +2197,7 @@ fn assert_bracket_pairs(
|
|||||||
selection_text: &'static str,
|
selection_text: &'static str,
|
||||||
bracket_pair_texts: Vec<&'static str>,
|
bracket_pair_texts: Vec<&'static str>,
|
||||||
language: Language,
|
language: Language,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
) {
|
) {
|
||||||
cx.set_global(Settings::test(cx));
|
cx.set_global(Settings::test(cx));
|
||||||
let (expected_text, selection_ranges) = marked_text_ranges(selection_text, false);
|
let (expected_text, selection_ranges) = marked_text_ranges(selection_text, false);
|
||||||
|
@ -16,7 +16,7 @@ use futures::{
|
|||||||
future::{BoxFuture, Shared},
|
future::{BoxFuture, Shared},
|
||||||
FutureExt, TryFutureExt as _,
|
FutureExt, TryFutureExt as _,
|
||||||
};
|
};
|
||||||
use gpui::{executor::Background, MutableAppContext, Task};
|
use gpui::{executor::Background, AppContext, Task};
|
||||||
use highlight_map::HighlightMap;
|
use highlight_map::HighlightMap;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use lsp::CodeActionKind;
|
use lsp::CodeActionKind;
|
||||||
@ -147,7 +147,7 @@ impl CachedLspAdapter {
|
|||||||
|
|
||||||
pub fn workspace_configuration(
|
pub fn workspace_configuration(
|
||||||
&self,
|
&self,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
) -> Option<BoxFuture<'static, Value>> {
|
) -> Option<BoxFuture<'static, Value>> {
|
||||||
self.adapter.workspace_configuration(cx)
|
self.adapter.workspace_configuration(cx)
|
||||||
}
|
}
|
||||||
@ -223,10 +223,7 @@ pub trait LspAdapter: 'static + Send + Sync {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
fn workspace_configuration(
|
fn workspace_configuration(&self, _: &mut AppContext) -> Option<BoxFuture<'static, Value>> {
|
||||||
&self,
|
|
||||||
_: &mut MutableAppContext,
|
|
||||||
) -> Option<BoxFuture<'static, Value>> {
|
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -584,7 +581,7 @@ impl LanguageRegistry {
|
|||||||
result
|
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 lsp_adapters = {
|
||||||
let state = self.state.read();
|
let state = self.state.read();
|
||||||
state
|
state
|
||||||
@ -769,7 +766,7 @@ impl LanguageRegistry {
|
|||||||
language: Arc<Language>,
|
language: Arc<Language>,
|
||||||
root_path: Arc<Path>,
|
root_path: Arc<Path>,
|
||||||
http_client: Arc<dyn HttpClient>,
|
http_client: Arc<dyn HttpClient>,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
) -> Option<Task<Result<lsp::LanguageServer>>> {
|
) -> Option<Task<Result<lsp::LanguageServer>>> {
|
||||||
#[cfg(any(test, feature = "test-support"))]
|
#[cfg(any(test, feature = "test-support"))]
|
||||||
if language.fake_adapter.is_some() {
|
if language.fake_adapter.is_some() {
|
||||||
|
@ -5,7 +5,7 @@ use editor::Editor;
|
|||||||
use fuzzy::{match_strings, StringMatch, StringMatchCandidate};
|
use fuzzy::{match_strings, StringMatch, StringMatchCandidate};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, elements::*, AnyViewHandle, AppContext, Entity, ModelHandle, MouseState,
|
actions, elements::*, AnyViewHandle, AppContext, Entity, ModelHandle, MouseState,
|
||||||
MutableAppContext, RenderContext, View, ViewContext, ViewHandle,
|
RenderContext, View, ViewContext, ViewHandle,
|
||||||
};
|
};
|
||||||
use language::{Buffer, LanguageRegistry};
|
use language::{Buffer, LanguageRegistry};
|
||||||
use picker::{Picker, PickerDelegate};
|
use picker::{Picker, PickerDelegate};
|
||||||
@ -16,7 +16,7 @@ use workspace::{AppState, Workspace};
|
|||||||
|
|
||||||
actions!(language_selector, [Toggle]);
|
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);
|
Picker::<LanguageSelector>::init(cx);
|
||||||
cx.add_action({
|
cx.add_action({
|
||||||
let language_registry = app_state.languages.clone();
|
let language_registry = app_state.languages.clone();
|
||||||
|
@ -89,6 +89,6 @@ fn main() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn quit(_: &Quit, cx: &mut gpui::MutableAppContext) {
|
fn quit(_: &Quit, cx: &mut gpui::AppContext) {
|
||||||
cx.platform().quit();
|
cx.platform().quit();
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ use editor::{
|
|||||||
use fuzzy::StringMatch;
|
use fuzzy::StringMatch;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, elements::*, geometry::vector::Vector2F, AnyViewHandle, AppContext, Entity,
|
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 language::Outline;
|
||||||
use ordered_float::OrderedFloat;
|
use ordered_float::OrderedFloat;
|
||||||
@ -16,7 +16,7 @@ use workspace::Workspace;
|
|||||||
|
|
||||||
actions!(outline, [Toggle]);
|
actions!(outline, [Toggle]);
|
||||||
|
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
cx.add_action(OutlineView::toggle);
|
cx.add_action(OutlineView::toggle);
|
||||||
Picker::<OutlineView>::init(cx);
|
Picker::<OutlineView>::init(cx);
|
||||||
}
|
}
|
||||||
@ -38,7 +38,7 @@ pub enum Event {
|
|||||||
impl Entity for OutlineView {
|
impl Entity for OutlineView {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
|
|
||||||
fn release(&mut self, cx: &mut MutableAppContext) {
|
fn release(&mut self, cx: &mut AppContext) {
|
||||||
self.restore_active_editor(cx);
|
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| {
|
self.active_editor.update(cx, |editor, cx| {
|
||||||
editor.highlight_rows(None);
|
editor.highlight_rows(None);
|
||||||
if let Some(scroll_position) = self.prev_scroll_position {
|
if let Some(scroll_position) = self.prev_scroll_position {
|
||||||
|
@ -4,8 +4,8 @@ use gpui::{
|
|||||||
geometry::vector::{vec2f, Vector2F},
|
geometry::vector::{vec2f, Vector2F},
|
||||||
keymap_matcher::KeymapContext,
|
keymap_matcher::KeymapContext,
|
||||||
platform::CursorStyle,
|
platform::CursorStyle,
|
||||||
AnyViewHandle, AppContext, Axis, Entity, MouseButton, MouseState, MutableAppContext,
|
AnyViewHandle, AppContext, Axis, Entity, MouseButton, MouseState, RenderContext, Task, View,
|
||||||
RenderContext, Task, View, ViewContext, ViewHandle, WeakViewHandle,
|
ViewContext, ViewHandle, WeakViewHandle,
|
||||||
};
|
};
|
||||||
use menu::{Cancel, Confirm, SelectFirst, SelectIndex, SelectLast, SelectNext, SelectPrev};
|
use menu::{Cancel, Confirm, SelectFirst, SelectIndex, SelectLast, SelectNext, SelectPrev};
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
@ -141,7 +141,7 @@ impl<D: PickerDelegate> View for Picker<D> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<D: PickerDelegate> 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_first);
|
||||||
cx.add_action(Self::select_last);
|
cx.add_action(Self::select_last);
|
||||||
cx.add_action(Self::select_next);
|
cx.add_action(Self::select_next);
|
||||||
|
@ -18,8 +18,8 @@ use futures::{
|
|||||||
AsyncWriteExt, Future, FutureExt, StreamExt, TryFutureExt,
|
AsyncWriteExt, Future, FutureExt, StreamExt, TryFutureExt,
|
||||||
};
|
};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
AnyModelHandle, AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle,
|
AnyModelHandle, AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, Task,
|
||||||
MutableAppContext, Task, UpgradeModelHandle, WeakModelHandle,
|
UpgradeModelHandle, WeakModelHandle,
|
||||||
};
|
};
|
||||||
use language::{
|
use language::{
|
||||||
point_to_lsp,
|
point_to_lsp,
|
||||||
@ -414,7 +414,7 @@ impl Project {
|
|||||||
user_store: ModelHandle<UserStore>,
|
user_store: ModelHandle<UserStore>,
|
||||||
languages: Arc<LanguageRegistry>,
|
languages: Arc<LanguageRegistry>,
|
||||||
fs: Arc<dyn Fs>,
|
fs: Arc<dyn Fs>,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
) -> ModelHandle<Self> {
|
) -> ModelHandle<Self> {
|
||||||
cx.add_model(|cx: &mut ModelContext<Self>| Self {
|
cx.add_model(|cx: &mut ModelContext<Self>| Self {
|
||||||
worktrees: Default::default(),
|
worktrees: Default::default(),
|
||||||
@ -6519,7 +6519,7 @@ impl<'a> Iterator for PathMatchCandidateSetIter<'a> {
|
|||||||
impl Entity for Project {
|
impl Entity for Project {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
|
|
||||||
fn release(&mut self, _: &mut gpui::MutableAppContext) {
|
fn release(&mut self, _: &mut gpui::AppContext) {
|
||||||
match &self.client_state {
|
match &self.client_state {
|
||||||
Some(ProjectClientState::Local { remote_id, .. }) => {
|
Some(ProjectClientState::Local { remote_id, .. }) => {
|
||||||
let _ = self.client.send(proto::UnshareProject {
|
let _ = self.client.send(proto::UnshareProject {
|
||||||
@ -6537,7 +6537,7 @@ impl Entity for Project {
|
|||||||
|
|
||||||
fn app_will_quit(
|
fn app_will_quit(
|
||||||
&mut self,
|
&mut self,
|
||||||
_: &mut MutableAppContext,
|
_: &mut AppContext,
|
||||||
) -> Option<std::pin::Pin<Box<dyn 'static + Future<Output = ()>>>> {
|
) -> Option<std::pin::Pin<Box<dyn 'static + Future<Output = ()>>>> {
|
||||||
let shutdown_futures = self
|
let shutdown_futures = self
|
||||||
.language_servers
|
.language_servers
|
||||||
|
@ -2,6 +2,7 @@ use crate::{worktree::WorktreeHandle, Event, *};
|
|||||||
use fs::LineEnding;
|
use fs::LineEnding;
|
||||||
use fs::{FakeFs, RealFs};
|
use fs::{FakeFs, RealFs};
|
||||||
use futures::{future, StreamExt};
|
use futures::{future, StreamExt};
|
||||||
|
use gpui::AppContext;
|
||||||
use gpui::{executor::Deterministic, test::subscribe};
|
use gpui::{executor::Deterministic, test::subscribe};
|
||||||
use language::{
|
use language::{
|
||||||
tree_sitter_rust, tree_sitter_typescript, Diagnostic, FakeLspAdapter, LanguageConfig,
|
tree_sitter_rust, tree_sitter_typescript, Diagnostic, FakeLspAdapter, LanguageConfig,
|
||||||
|
@ -16,10 +16,7 @@ use futures::{
|
|||||||
};
|
};
|
||||||
use fuzzy::CharBag;
|
use fuzzy::CharBag;
|
||||||
use git::{DOT_GIT, GITIGNORE};
|
use git::{DOT_GIT, GITIGNORE};
|
||||||
use gpui::{
|
use gpui::{executor, AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, Task};
|
||||||
executor, AppContext, AsyncAppContext, Entity, ModelContext, ModelHandle, MutableAppContext,
|
|
||||||
Task,
|
|
||||||
};
|
|
||||||
use language::{
|
use language::{
|
||||||
proto::{
|
proto::{
|
||||||
deserialize_fingerprint, deserialize_version, serialize_fingerprint, serialize_line_ending,
|
deserialize_fingerprint, deserialize_version, serialize_fingerprint, serialize_line_ending,
|
||||||
@ -287,7 +284,7 @@ impl Worktree {
|
|||||||
replica_id: ReplicaId,
|
replica_id: ReplicaId,
|
||||||
worktree: proto::WorktreeMetadata,
|
worktree: proto::WorktreeMetadata,
|
||||||
client: Arc<Client>,
|
client: Arc<Client>,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
) -> ModelHandle<Self> {
|
) -> ModelHandle<Self> {
|
||||||
cx.add_model(|cx: &mut ModelContext<Self>| {
|
cx.add_model(|cx: &mut ModelContext<Self>| {
|
||||||
let snapshot = Snapshot {
|
let snapshot = Snapshot {
|
||||||
@ -1896,7 +1893,7 @@ impl language::LocalFile for File {
|
|||||||
fingerprint: RopeFingerprint,
|
fingerprint: RopeFingerprint,
|
||||||
line_ending: LineEnding,
|
line_ending: LineEnding,
|
||||||
mtime: SystemTime,
|
mtime: SystemTime,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
) {
|
) {
|
||||||
let worktree = self.worktree.read(cx).as_local().unwrap();
|
let worktree = self.worktree.read(cx).as_local().unwrap();
|
||||||
if let Some(project_id) = worktree.share.as_ref().map(|share| share.project_id) {
|
if let Some(project_id) = worktree.share.as_ref().map(|share| share.project_id) {
|
||||||
|
@ -13,8 +13,8 @@ use gpui::{
|
|||||||
impl_internal_actions,
|
impl_internal_actions,
|
||||||
keymap_matcher::KeymapContext,
|
keymap_matcher::KeymapContext,
|
||||||
platform::CursorStyle,
|
platform::CursorStyle,
|
||||||
AppContext, ClipboardItem, Element, ElementBox, Entity, ModelHandle, MouseButton,
|
AppContext, ClipboardItem, Element, ElementBox, Entity, ModelHandle, MouseButton, PromptLevel,
|
||||||
MutableAppContext, PromptLevel, RenderContext, Task, View, ViewContext, ViewHandle,
|
RenderContext, Task, View, ViewContext, ViewHandle,
|
||||||
};
|
};
|
||||||
use menu::{Confirm, SelectNext, SelectPrev};
|
use menu::{Confirm, SelectNext, SelectPrev};
|
||||||
use project::{Entry, EntryKind, Project, ProjectEntryId, ProjectPath, Worktree, WorktreeId};
|
use project::{Entry, EntryKind, Project, ProjectEntryId, ProjectPath, Worktree, WorktreeId};
|
||||||
@ -132,7 +132,7 @@ impl_internal_actions!(
|
|||||||
[Open, ToggleExpanded, DeployContextMenu, MoveProjectEntry]
|
[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::deploy_context_menu);
|
||||||
cx.add_action(ProjectPanel::expand_selected_entry);
|
cx.add_action(ProjectPanel::expand_selected_entry);
|
||||||
cx.add_action(ProjectPanel::collapse_selected_entry);
|
cx.add_action(ProjectPanel::collapse_selected_entry);
|
||||||
|
@ -5,7 +5,7 @@ use editor::{
|
|||||||
use fuzzy::{StringMatch, StringMatchCandidate};
|
use fuzzy::{StringMatch, StringMatchCandidate};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, elements::*, AnyViewHandle, AppContext, Entity, ModelHandle, MouseState,
|
actions, elements::*, AnyViewHandle, AppContext, Entity, ModelHandle, MouseState,
|
||||||
MutableAppContext, RenderContext, Task, View, ViewContext, ViewHandle,
|
RenderContext, Task, View, ViewContext, ViewHandle,
|
||||||
};
|
};
|
||||||
use ordered_float::OrderedFloat;
|
use ordered_float::OrderedFloat;
|
||||||
use picker::{Picker, PickerDelegate};
|
use picker::{Picker, PickerDelegate};
|
||||||
@ -17,7 +17,7 @@ use workspace::Workspace;
|
|||||||
|
|
||||||
actions!(project_symbols, [Toggle]);
|
actions!(project_symbols, [Toggle]);
|
||||||
|
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
cx.add_action(ProjectSymbolsView::toggle);
|
cx.add_action(ProjectSymbolsView::toggle);
|
||||||
Picker::<ProjectSymbolsView>::init(cx);
|
Picker::<ProjectSymbolsView>::init(cx);
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ use fuzzy::{StringMatch, StringMatchCandidate};
|
|||||||
use gpui::{
|
use gpui::{
|
||||||
actions,
|
actions,
|
||||||
elements::{ChildView, Flex, ParentElement},
|
elements::{ChildView, Flex, ParentElement},
|
||||||
AnyViewHandle, Element, ElementBox, Entity, MutableAppContext, RenderContext, Task, View,
|
AnyViewHandle, Element, ElementBox, Entity, AppContext, RenderContext, Task, View,
|
||||||
ViewContext, ViewHandle,
|
ViewContext, ViewHandle,
|
||||||
};
|
};
|
||||||
use highlighted_workspace_location::HighlightedWorkspaceLocation;
|
use highlighted_workspace_location::HighlightedWorkspaceLocation;
|
||||||
@ -18,7 +18,7 @@ use workspace::{
|
|||||||
|
|
||||||
actions!(projects, [OpenRecent]);
|
actions!(projects, [OpenRecent]);
|
||||||
|
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
cx.add_action(RecentProjectsView::toggle);
|
cx.add_action(RecentProjectsView::toggle);
|
||||||
Picker::<RecentProjectsView>::init(cx);
|
Picker::<RecentProjectsView>::init(cx);
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,7 @@ use collections::HashMap;
|
|||||||
use editor::Editor;
|
use editor::Editor;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, elements::*, impl_actions, platform::CursorStyle, Action, AnyViewHandle, AppContext,
|
actions, elements::*, impl_actions, platform::CursorStyle, Action, AnyViewHandle, AppContext,
|
||||||
Entity, MouseButton, MutableAppContext, RenderContext, Subscription, Task, View, ViewContext,
|
Entity, MouseButton, RenderContext, Subscription, Task, View, ViewContext, ViewHandle,
|
||||||
ViewHandle,
|
|
||||||
};
|
};
|
||||||
use project::search::SearchQuery;
|
use project::search::SearchQuery;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
@ -31,7 +30,7 @@ pub enum Event {
|
|||||||
UpdateLocation,
|
UpdateLocation,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
cx.add_action(BufferSearchBar::deploy);
|
cx.add_action(BufferSearchBar::deploy);
|
||||||
cx.add_action(BufferSearchBar::dismiss);
|
cx.add_action(BufferSearchBar::dismiss);
|
||||||
cx.add_action(BufferSearchBar::focus_editor);
|
cx.add_action(BufferSearchBar::focus_editor);
|
||||||
@ -45,7 +44,7 @@ pub fn init(cx: &mut MutableAppContext) {
|
|||||||
add_toggle_option_action::<ToggleRegex>(SearchOption::Regex, cx);
|
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>| {
|
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 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)) {
|
if search_bar.update(cx, |search_bar, cx| search_bar.show(false, false, cx)) {
|
||||||
|
@ -10,8 +10,8 @@ use editor::{
|
|||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, elements::*, platform::CursorStyle, Action, AnyViewHandle, AppContext, ElementBox,
|
actions, elements::*, platform::CursorStyle, Action, AnyViewHandle, AppContext, ElementBox,
|
||||||
Entity, ModelContext, ModelHandle, MouseButton, MutableAppContext, RenderContext, Subscription,
|
Entity, ModelContext, ModelHandle, MouseButton, RenderContext, Subscription, Task, View,
|
||||||
Task, View, ViewContext, ViewHandle, WeakModelHandle, WeakViewHandle,
|
ViewContext, ViewHandle, WeakModelHandle, WeakViewHandle,
|
||||||
};
|
};
|
||||||
use menu::Confirm;
|
use menu::Confirm;
|
||||||
use project::{search::SearchQuery, Project};
|
use project::{search::SearchQuery, Project};
|
||||||
@ -36,7 +36,7 @@ actions!(project_search, [SearchInNew, ToggleFocus]);
|
|||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct ActiveSearches(HashMap<WeakModelHandle<Project>, WeakViewHandle<ProjectSearchView>>);
|
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.set_global(ActiveSearches::default());
|
||||||
cx.add_action(ProjectSearchView::deploy);
|
cx.add_action(ProjectSearchView::deploy);
|
||||||
cx.add_action(ProjectSearchBar::search);
|
cx.add_action(ProjectSearchBar::search);
|
||||||
@ -50,7 +50,7 @@ pub fn init(cx: &mut MutableAppContext) {
|
|||||||
add_toggle_option_action::<ToggleRegex>(SearchOption::Regex, cx);
|
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>| {
|
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 let Some(search_bar) = pane.toolbar().read(cx).item_of_type::<ProjectSearchBar>() {
|
||||||
if search_bar.update(cx, |search_bar, cx| {
|
if search_bar.update(cx, |search_bar, cx| {
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
pub use buffer_search::BufferSearchBar;
|
pub use buffer_search::BufferSearchBar;
|
||||||
use gpui::{actions, Action, MutableAppContext};
|
use gpui::{actions, Action, AppContext};
|
||||||
pub use project_search::{ProjectSearchBar, ProjectSearchView};
|
pub use project_search::{ProjectSearchBar, ProjectSearchView};
|
||||||
|
|
||||||
pub mod buffer_search;
|
pub mod buffer_search;
|
||||||
pub mod project_search;
|
pub mod project_search;
|
||||||
|
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
buffer_search::init(cx);
|
buffer_search::init(cx);
|
||||||
project_search::init(cx);
|
project_search::init(cx);
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ use crate::{parse_json_with_comments, Settings};
|
|||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use assets::Assets;
|
use assets::Assets;
|
||||||
use collections::BTreeMap;
|
use collections::BTreeMap;
|
||||||
use gpui::{keymap_matcher::Binding, MutableAppContext};
|
use gpui::{keymap_matcher::Binding, AppContext};
|
||||||
use schemars::{
|
use schemars::{
|
||||||
gen::{SchemaGenerator, SchemaSettings},
|
gen::{SchemaGenerator, SchemaSettings},
|
||||||
schema::{InstanceType, Schema, SchemaObject, SingleOrVec, SubschemaValidation},
|
schema::{InstanceType, Schema, SchemaObject, SingleOrVec, SubschemaValidation},
|
||||||
@ -41,7 +41,7 @@ impl JsonSchema for KeymapAction {
|
|||||||
struct ActionWithData(Box<str>, Box<RawValue>);
|
struct ActionWithData(Box<str>, Box<RawValue>);
|
||||||
|
|
||||||
impl KeymapFileContent {
|
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"] {
|
for path in ["keymaps/default.json", "keymaps/vim.json"] {
|
||||||
Self::load(path, cx).unwrap();
|
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 = Assets::get(asset_path).unwrap().data;
|
||||||
let content_str = std::str::from_utf8(content.as_ref()).unwrap();
|
let content_str = std::str::from_utf8(content.as_ref()).unwrap();
|
||||||
parse_json_with_comments::<Self>(content_str)?.add_to_cx(cx)
|
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 {
|
for KeymapBlock { context, bindings } in self.0 {
|
||||||
let bindings = bindings
|
let bindings = bindings
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
@ -2,7 +2,7 @@ use crate::{update_settings_file, watched_json::WatchedJsonFile, SettingsFileCon
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use assets::Assets;
|
use assets::Assets;
|
||||||
use fs::Fs;
|
use fs::Fs;
|
||||||
use gpui::{AssetSource, MutableAppContext};
|
use gpui::{AppContext, AssetSource};
|
||||||
use std::{io::ErrorKind, path::Path, sync::Arc};
|
use std::{io::ErrorKind, path::Path, sync::Arc};
|
||||||
|
|
||||||
// TODO: Switch SettingsFile to open a worktree and buffer for synchronization
|
// TODO: Switch SettingsFile to open a worktree and buffer for synchronization
|
||||||
@ -49,7 +49,7 @@ impl SettingsFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(
|
pub fn update(
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
update: impl 'static + Send + FnOnce(&mut SettingsFileContent),
|
update: impl 'static + Send + FnOnce(&mut SettingsFileContent),
|
||||||
) {
|
) {
|
||||||
let this = cx.global::<SettingsFile>();
|
let this = cx.global::<SettingsFile>();
|
||||||
@ -211,7 +211,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn assert_key_bindings_for<'a>(
|
fn assert_key_bindings_for<'a>(
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
actions: Vec<(&'static str, &'a dyn Action)>,
|
actions: Vec<(&'static str, &'a dyn Action)>,
|
||||||
line: u32,
|
line: u32,
|
||||||
) {
|
) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use fs::Fs;
|
use fs::Fs;
|
||||||
use futures::StreamExt;
|
use futures::StreamExt;
|
||||||
use gpui::{executor, MutableAppContext};
|
use gpui::{executor, AppContext};
|
||||||
use postage::sink::Sink as _;
|
use postage::sink::Sink as _;
|
||||||
use postage::{prelude::Stream, watch};
|
use postage::{prelude::Stream, watch};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
@ -67,7 +67,7 @@ pub fn watch_files(
|
|||||||
settings_file: WatchedJsonFile<SettingsFileContent>,
|
settings_file: WatchedJsonFile<SettingsFileContent>,
|
||||||
theme_registry: Arc<ThemeRegistry>,
|
theme_registry: Arc<ThemeRegistry>,
|
||||||
keymap_file: WatchedJsonFile<KeymapFileContent>,
|
keymap_file: WatchedJsonFile<KeymapFileContent>,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
) {
|
) {
|
||||||
watch_settings_file(defaults, settings_file, theme_registry, cx);
|
watch_settings_file(defaults, settings_file, theme_registry, cx);
|
||||||
watch_keymap_file(keymap_file, cx);
|
watch_keymap_file(keymap_file, cx);
|
||||||
@ -77,7 +77,7 @@ pub(crate) fn watch_settings_file(
|
|||||||
defaults: Settings,
|
defaults: Settings,
|
||||||
mut file: WatchedJsonFile<SettingsFileContent>,
|
mut file: WatchedJsonFile<SettingsFileContent>,
|
||||||
theme_registry: Arc<ThemeRegistry>,
|
theme_registry: Arc<ThemeRegistry>,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
) {
|
) {
|
||||||
settings_updated(&defaults, file.0.borrow().clone(), &theme_registry, cx);
|
settings_updated(&defaults, file.0.borrow().clone(), &theme_registry, cx);
|
||||||
cx.spawn(|mut cx| async move {
|
cx.spawn(|mut cx| async move {
|
||||||
@ -88,7 +88,7 @@ pub(crate) fn watch_settings_file(
|
|||||||
.detach();
|
.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn keymap_updated(content: KeymapFileContent, cx: &mut MutableAppContext) {
|
fn keymap_updated(content: KeymapFileContent, cx: &mut AppContext) {
|
||||||
cx.clear_bindings();
|
cx.clear_bindings();
|
||||||
KeymapFileContent::load_defaults(cx);
|
KeymapFileContent::load_defaults(cx);
|
||||||
content.add_to_cx(cx).log_err();
|
content.add_to_cx(cx).log_err();
|
||||||
@ -98,7 +98,7 @@ fn settings_updated(
|
|||||||
defaults: &Settings,
|
defaults: &Settings,
|
||||||
content: SettingsFileContent,
|
content: SettingsFileContent,
|
||||||
theme_registry: &Arc<ThemeRegistry>,
|
theme_registry: &Arc<ThemeRegistry>,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
) {
|
) {
|
||||||
let mut settings = defaults.clone();
|
let mut settings = defaults.clone();
|
||||||
settings.set_user_settings(content, theme_registry, cx.font_cache());
|
settings.set_user_settings(content, theme_registry, cx.font_cache());
|
||||||
@ -106,7 +106,7 @@ fn settings_updated(
|
|||||||
cx.refresh_windows();
|
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 {
|
cx.spawn(|mut cx| async move {
|
||||||
let mut settings_subscription = None;
|
let mut settings_subscription = None;
|
||||||
while let Some(content) = file.0.recv().await {
|
while let Some(content) = file.0.recv().await {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use gpui::MutableAppContext;
|
use gpui::AppContext;
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct StaffMode(pub bool);
|
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
|
/// 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.
|
/// as soon as we know that the staff mode is enabled.
|
||||||
pub fn staff_mode<F: FnMut(&mut MutableAppContext) + 'static>(
|
pub fn staff_mode<F: FnMut(&mut AppContext) + 'static>(
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
mut init: F,
|
mut init: F,
|
||||||
) {
|
) {
|
||||||
if **cx.default_global::<StaffMode>() {
|
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.
|
/// Immediately checks and runs the init function if the staff mode is not enabled.
|
||||||
/// This is only included for symettry with staff_mode() above
|
/// This is only included for symettry with staff_mode() above
|
||||||
pub fn not_staff_mode<F: FnOnce(&mut MutableAppContext) + 'static>(
|
pub fn not_staff_mode<F: FnOnce(&mut AppContext) + 'static>(
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
init: F,
|
init: F,
|
||||||
) {
|
) {
|
||||||
if !**cx.default_global::<StaffMode>() {
|
if !**cx.default_global::<StaffMode>() {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use context_menu::{ContextMenu, ContextMenuItem};
|
use context_menu::{ContextMenu, ContextMenuItem};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
elements::*, impl_internal_actions, CursorStyle, Element, ElementBox, Entity, MouseButton,
|
elements::*, impl_internal_actions, CursorStyle, Element, ElementBox, Entity, MouseButton,
|
||||||
MutableAppContext, RenderContext, View, ViewContext, ViewHandle, WeakModelHandle,
|
AppContext, RenderContext, View, ViewContext, ViewHandle, WeakModelHandle,
|
||||||
WeakViewHandle,
|
WeakViewHandle,
|
||||||
};
|
};
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
@ -21,7 +21,7 @@ pub struct FocusTerminal {
|
|||||||
|
|
||||||
impl_internal_actions!(terminal, [FocusTerminal, DeployTerminalMenu]);
|
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::deploy_terminal_menu);
|
||||||
cx.add_action(TerminalButton::focus_terminal);
|
cx.add_action(TerminalButton::focus_terminal);
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,8 @@ use gpui::{
|
|||||||
geometry::vector::Vector2F,
|
geometry::vector::Vector2F,
|
||||||
impl_actions, impl_internal_actions,
|
impl_actions, impl_internal_actions,
|
||||||
keymap_matcher::{KeymapContext, Keystroke},
|
keymap_matcher::{KeymapContext, Keystroke},
|
||||||
AnyViewHandle, AppContext, Element, ElementBox, Entity, ModelHandle, MutableAppContext, Task,
|
AnyViewHandle, AppContext, Element, ElementBox, Entity, ModelHandle, Task, View, ViewContext,
|
||||||
View, ViewContext, ViewHandle, WeakViewHandle,
|
ViewHandle, WeakViewHandle,
|
||||||
};
|
};
|
||||||
use project::{LocalWorktree, Project};
|
use project::{LocalWorktree, Project};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
@ -68,7 +68,7 @@ impl_actions!(terminal, [SendText, SendKeystroke]);
|
|||||||
|
|
||||||
impl_internal_actions!(project_panel, [DeployContextMenu]);
|
impl_internal_actions!(project_panel, [DeployContextMenu]);
|
||||||
|
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
cx.add_action(TerminalView::deploy);
|
cx.add_action(TerminalView::deploy);
|
||||||
|
|
||||||
register_deserializable_item::<TerminalView>(cx);
|
register_deserializable_item::<TerminalView>(cx);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use fuzzy::{match_strings, StringMatch, StringMatchCandidate};
|
use fuzzy::{match_strings, StringMatch, StringMatchCandidate};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, elements::*, AnyViewHandle, AppContext, Element, ElementBox, Entity, MouseState,
|
actions, elements::*, AnyViewHandle, AppContext, Element, ElementBox, Entity, MouseState,
|
||||||
MutableAppContext, RenderContext, View, ViewContext, ViewHandle,
|
RenderContext, View, ViewContext, ViewHandle,
|
||||||
};
|
};
|
||||||
use picker::{Picker, PickerDelegate};
|
use picker::{Picker, PickerDelegate};
|
||||||
use settings::{settings_file::SettingsFile, Settings};
|
use settings::{settings_file::SettingsFile, Settings};
|
||||||
@ -22,7 +22,7 @@ pub struct ThemeSelector {
|
|||||||
|
|
||||||
actions!(theme_selector, [Toggle, Reload]);
|
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);
|
Picker::<ThemeSelector>::init(cx);
|
||||||
cx.add_action({
|
cx.add_action({
|
||||||
let theme_registry = app_state.themes.clone();
|
let theme_registry = app_state.themes.clone();
|
||||||
@ -83,7 +83,7 @@ impl ThemeSelector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[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();
|
let current_theme_name = cx.global::<Settings>().theme.meta.name.clone();
|
||||||
themes.clear();
|
themes.clear();
|
||||||
match themes.get(¤t_theme_name) {
|
match themes.get(¤t_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| {
|
cx.update_global::<Settings, _, _>(|settings, cx| {
|
||||||
settings.theme = theme;
|
settings.theme = theme;
|
||||||
cx.refresh_windows();
|
cx.refresh_windows();
|
||||||
@ -243,7 +243,7 @@ impl PickerDelegate for ThemeSelector {
|
|||||||
impl Entity for ThemeSelector {
|
impl Entity for ThemeSelector {
|
||||||
type Event = Event;
|
type Event = Event;
|
||||||
|
|
||||||
fn release(&mut self, cx: &mut MutableAppContext) {
|
fn release(&mut self, cx: &mut AppContext) {
|
||||||
if !self.selection_completed {
|
if !self.selection_completed {
|
||||||
Self::set_theme(self.original_theme.clone(), cx);
|
Self::set_theme(self.original_theme.clone(), cx);
|
||||||
}
|
}
|
||||||
|
@ -6,8 +6,8 @@ use gpui::{
|
|||||||
Padding, ParentElement,
|
Padding, ParentElement,
|
||||||
},
|
},
|
||||||
fonts::TextStyle,
|
fonts::TextStyle,
|
||||||
AppContext, Border, Element, Entity, ModelHandle, MutableAppContext, Quad, RenderContext, Task,
|
AppContext, Border, Element, Entity, ModelHandle, Quad, RenderContext, Task, View, ViewContext,
|
||||||
View, ViewContext, ViewHandle, WeakViewHandle,
|
ViewHandle, WeakViewHandle,
|
||||||
};
|
};
|
||||||
use project::Project;
|
use project::Project;
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
@ -16,7 +16,7 @@ use workspace::{item::Item, register_deserializable_item, Pane, Workspace};
|
|||||||
|
|
||||||
actions!(theme, [DeployThemeTestbench]);
|
actions!(theme, [DeployThemeTestbench]);
|
||||||
|
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
cx.add_action(ThemeTestbench::deploy);
|
cx.add_action(ThemeTestbench::deploy);
|
||||||
|
|
||||||
register_deserializable_item::<ThemeTestbench>(cx)
|
register_deserializable_item::<ThemeTestbench>(cx)
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
use editor::{EditorBlurred, EditorFocused, EditorMode, EditorReleased, Event};
|
use editor::{EditorBlurred, EditorFocused, EditorMode, EditorReleased, Event};
|
||||||
use gpui::MutableAppContext;
|
use gpui::AppContext;
|
||||||
|
|
||||||
use crate::{state::Mode, Vim};
|
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(focused).detach();
|
||||||
cx.subscribe_global(blurred).detach();
|
cx.subscribe_global(blurred).detach();
|
||||||
cx.subscribe_global(released).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| {
|
Vim::update(cx, |vim, cx| {
|
||||||
if let Some(previously_active_editor) = vim
|
if let Some(previously_active_editor) = vim
|
||||||
.active_editor
|
.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| {
|
Vim::update(cx, |vim, cx| {
|
||||||
if let Some(previous_editor) = vim.active_editor.clone() {
|
if let Some(previous_editor) = vim.active_editor.clone() {
|
||||||
if previous_editor == 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, _| {
|
cx.update_default_global(|vim: &mut Vim, _| {
|
||||||
if let Some(previous_editor) = vim.active_editor.clone() {
|
if let Some(previous_editor) = vim.active_editor.clone() {
|
||||||
if previous_editor == 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| {
|
Vim::update(cx, |vim, cx| {
|
||||||
if vim.enabled && vim.state.mode == Mode::Normal && !newest_empty {
|
if vim.enabled && vim.state.mode == Mode::Normal && !newest_empty {
|
||||||
vim.switch_mode(Mode::Visual { line: false }, false, cx)
|
vim.switch_mode(Mode::Visual { line: false }, false, cx)
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
use crate::{state::Mode, Vim};
|
use crate::{state::Mode, Vim};
|
||||||
use editor::{scroll::autoscroll::Autoscroll, Bias};
|
use editor::{scroll::autoscroll::Autoscroll, Bias};
|
||||||
use gpui::{actions, MutableAppContext, ViewContext};
|
use gpui::{actions, AppContext, ViewContext};
|
||||||
use language::SelectionGoal;
|
use language::SelectionGoal;
|
||||||
use workspace::Workspace;
|
use workspace::Workspace;
|
||||||
|
|
||||||
actions!(vim, [NormalBefore]);
|
actions!(vim, [NormalBefore]);
|
||||||
|
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
cx.add_action(normal_before);
|
cx.add_action(normal_before);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ use editor::{
|
|||||||
display_map::{DisplaySnapshot, ToDisplayPoint},
|
display_map::{DisplaySnapshot, ToDisplayPoint},
|
||||||
movement, Bias, CharKind, DisplayPoint, ToOffset,
|
movement, Bias, CharKind, DisplayPoint, ToOffset,
|
||||||
};
|
};
|
||||||
use gpui::{actions, impl_actions, MutableAppContext};
|
use gpui::{actions, impl_actions, AppContext};
|
||||||
use language::{Point, Selection, SelectionGoal};
|
use language::{Point, Selection, SelectionGoal};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use workspace::Workspace;
|
use workspace::Workspace;
|
||||||
@ -80,7 +80,7 @@ actions!(
|
|||||||
);
|
);
|
||||||
impl_actions!(vim, [NextWordStart, NextWordEnd, PreviousWordStart]);
|
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, _: &Left, cx: _| motion(Motion::Left, cx));
|
||||||
cx.add_action(|_: &mut Workspace, _: &Backspace, cx: _| motion(Motion::Backspace, cx));
|
cx.add_action(|_: &mut Workspace, _: &Backspace, cx: _| motion(Motion::Backspace, cx));
|
||||||
cx.add_action(|_: &mut Workspace, _: &Down, cx: _| motion(Motion::Down, 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))
|
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(_))
|
if let Some(Operator::Namespace(_))
|
||||||
| Some(Operator::FindForward { .. })
|
| Some(Operator::FindForward { .. })
|
||||||
| Some(Operator::FindBackward { .. }) = Vim::read(cx).active_operator()
|
| Some(Operator::FindBackward { .. }) = Vim::read(cx).active_operator()
|
||||||
|
@ -16,7 +16,7 @@ use editor::{
|
|||||||
scroll::{autoscroll::Autoscroll, scroll_amount::ScrollAmount},
|
scroll::{autoscroll::Autoscroll, scroll_amount::ScrollAmount},
|
||||||
Anchor, Bias, ClipboardSelection, DisplayPoint, Editor,
|
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 language::{AutoindentMode, Point, SelectionGoal};
|
||||||
use log::error;
|
use log::error;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
@ -50,7 +50,7 @@ actions!(
|
|||||||
|
|
||||||
impl_actions!(vim, [Scroll]);
|
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_after);
|
||||||
cx.add_action(insert_first_non_whitespace);
|
cx.add_action(insert_first_non_whitespace);
|
||||||
cx.add_action(insert_end_of_line);
|
cx.add_action(insert_end_of_line);
|
||||||
@ -94,7 +94,7 @@ pub fn normal_motion(
|
|||||||
motion: Motion,
|
motion: Motion,
|
||||||
operator: Option<Operator>,
|
operator: Option<Operator>,
|
||||||
times: usize,
|
times: usize,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
) {
|
) {
|
||||||
Vim::update(cx, |vim, cx| {
|
Vim::update(cx, |vim, cx| {
|
||||||
match operator {
|
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| {
|
Vim::update(cx, |vim, cx| {
|
||||||
match vim.state.operator_stack.pop() {
|
match vim.state.operator_stack.pop() {
|
||||||
Some(Operator::Object { around }) => 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| {
|
vim.update_active_editor(cx, |editor, cx| {
|
||||||
editor.change_selections(Some(Autoscroll::fit()), cx, |s| {
|
editor.change_selections(Some(Autoscroll::fit()), cx, |s| {
|
||||||
s.move_cursors_with(|map, cursor, goal| {
|
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(cx, |vim, cx| {
|
||||||
vim.update_active_editor(cx, |editor, cx| {
|
vim.update_active_editor(cx, |editor, cx| {
|
||||||
editor.transact(cx, |editor, cx| {
|
editor.transact(cx, |editor, cx| {
|
||||||
|
@ -3,10 +3,10 @@ use editor::{
|
|||||||
char_kind, display_map::DisplaySnapshot, movement, scroll::autoscroll::Autoscroll, CharKind,
|
char_kind, display_map::DisplaySnapshot, movement, scroll::autoscroll::Autoscroll, CharKind,
|
||||||
DisplayPoint,
|
DisplayPoint,
|
||||||
};
|
};
|
||||||
use gpui::MutableAppContext;
|
use gpui::AppContext;
|
||||||
use language::Selection;
|
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
|
// Some motions ignore failure when switching to normal mode
|
||||||
let mut motion_succeeded = matches!(
|
let mut motion_succeeded = matches!(
|
||||||
motion,
|
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;
|
let mut objects_found = false;
|
||||||
vim.update_active_editor(cx, |editor, cx| {
|
vim.update_active_editor(cx, |editor, cx| {
|
||||||
// We are swapping to insert mode anyway. Just set the line end clipping behavior now
|
// We are swapping to insert mode anyway. Just set the line end clipping behavior now
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
use crate::{motion::Motion, object::Object, utils::copy_selections_content, Vim};
|
use crate::{motion::Motion, object::Object, utils::copy_selections_content, Vim};
|
||||||
use collections::{HashMap, HashSet};
|
use collections::{HashMap, HashSet};
|
||||||
use editor::{display_map::ToDisplayPoint, scroll::autoscroll::Autoscroll, Bias};
|
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| {
|
vim.update_active_editor(cx, |editor, cx| {
|
||||||
editor.transact(cx, |editor, cx| {
|
editor.transact(cx, |editor, cx| {
|
||||||
editor.set_clip_at_line_ends(false, 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| {
|
vim.update_active_editor(cx, |editor, cx| {
|
||||||
editor.transact(cx, |editor, cx| {
|
editor.transact(cx, |editor, cx| {
|
||||||
editor.set_clip_at_line_ends(false, cx);
|
editor.set_clip_at_line_ends(false, cx);
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
use crate::{motion::Motion, object::Object, utils::copy_selections_content, Vim};
|
use crate::{motion::Motion, object::Object, utils::copy_selections_content, Vim};
|
||||||
use collections::HashMap;
|
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| {
|
vim.update_active_editor(cx, |editor, cx| {
|
||||||
editor.transact(cx, |editor, cx| {
|
editor.transact(cx, |editor, cx| {
|
||||||
editor.set_clip_at_line_ends(false, 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| {
|
vim.update_active_editor(cx, |editor, cx| {
|
||||||
editor.transact(cx, |editor, cx| {
|
editor.transact(cx, |editor, cx| {
|
||||||
editor.set_clip_at_line_ends(false, cx);
|
editor.set_clip_at_line_ends(false, cx);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use std::ops::Range;
|
use std::ops::Range;
|
||||||
|
|
||||||
use editor::{char_kind, display_map::DisplaySnapshot, movement, Bias, CharKind, DisplayPoint};
|
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 language::Selection;
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use workspace::Workspace;
|
use workspace::Workspace;
|
||||||
@ -43,7 +43,7 @@ actions!(
|
|||||||
);
|
);
|
||||||
impl_actions!(vim, [Word]);
|
impl_actions!(vim, [Word]);
|
||||||
|
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
cx.add_action(
|
cx.add_action(
|
||||||
|_: &mut Workspace, &Word { ignore_punctuation }: &Word, cx: _| {
|
|_: &mut Workspace, &Word { ignore_punctuation }: &Word, cx: _| {
|
||||||
object(Object::Word { ignore_punctuation }, 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));
|
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 {
|
match Vim::read(cx).state.mode {
|
||||||
Mode::Normal => normal_object(object, cx),
|
Mode::Normal => normal_object(object, cx),
|
||||||
Mode::Visual { .. } => visual_object(object, cx),
|
Mode::Visual { .. } => visual_object(object, cx),
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use editor::{ClipboardSelection, Editor};
|
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 selections = editor.selections.all_adjusted(cx);
|
||||||
let buffer = editor.buffer().read(cx).snapshot(cx);
|
let buffer = editor.buffer().read(cx).snapshot(cx);
|
||||||
let mut text = String::new();
|
let mut text = String::new();
|
||||||
|
@ -15,7 +15,7 @@ use std::sync::Arc;
|
|||||||
use collections::CommandPaletteFilter;
|
use collections::CommandPaletteFilter;
|
||||||
use editor::{Bias, Cancel, Editor, EditorMode};
|
use editor::{Bias, Cancel, Editor, EditorMode};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, impl_actions, MutableAppContext, Subscription, ViewContext, ViewHandle, WeakViewHandle,
|
actions, impl_actions, AppContext, Subscription, ViewContext, ViewHandle, WeakViewHandle,
|
||||||
};
|
};
|
||||||
use language::CursorShape;
|
use language::CursorShape;
|
||||||
use motion::Motion;
|
use motion::Motion;
|
||||||
@ -38,7 +38,7 @@ struct Number(u8);
|
|||||||
actions!(vim, [Tab, Enter]);
|
actions!(vim, [Tab, Enter]);
|
||||||
impl_actions!(vim, [Number, SwitchMode, PushOperator]);
|
impl_actions!(vim, [Number, SwitchMode, PushOperator]);
|
||||||
|
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
editor_events::init(cx);
|
editor_events::init(cx);
|
||||||
normal::init(cx);
|
normal::init(cx);
|
||||||
visual::init(cx);
|
visual::init(cx);
|
||||||
@ -65,7 +65,7 @@ pub fn init(cx: &mut MutableAppContext) {
|
|||||||
// Otherwise forward cancel on to the editor
|
// Otherwise forward cancel on to the editor
|
||||||
let vim = Vim::read(cx);
|
let vim = Vim::read(cx);
|
||||||
if vim.state.mode != Mode::Normal || vim.active_operator().is_some() {
|
if vim.state.mode != Mode::Normal || vim.active_operator().is_some() {
|
||||||
MutableAppContext::defer(cx, |cx| {
|
AppContext::defer(cx, |cx| {
|
||||||
Vim::update(cx, |state, cx| {
|
Vim::update(cx, |state, cx| {
|
||||||
state.switch_mode(Mode::Normal, false, cx);
|
state.switch_mode(Mode::Normal, false, cx);
|
||||||
});
|
});
|
||||||
@ -95,7 +95,7 @@ pub fn init(cx: &mut MutableAppContext) {
|
|||||||
.detach();
|
.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| {
|
cx.observe_keystrokes(window_id, |_keystroke, _result, handled_by, cx| {
|
||||||
if let Some(handled_by) = handled_by {
|
if let Some(handled_by) = handled_by {
|
||||||
// Keystroke is handled by the vim system, so continue forward
|
// Keystroke is handled by the vim system, so continue forward
|
||||||
@ -131,20 +131,20 @@ pub struct Vim {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Vim {
|
impl Vim {
|
||||||
fn read(cx: &mut MutableAppContext) -> &Self {
|
fn read(cx: &mut AppContext) -> &Self {
|
||||||
cx.default_global()
|
cx.default_global()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update<F, S>(cx: &mut MutableAppContext, update: F) -> S
|
fn update<F, S>(cx: &mut AppContext, update: F) -> S
|
||||||
where
|
where
|
||||||
F: FnOnce(&mut Self, &mut MutableAppContext) -> S,
|
F: FnOnce(&mut Self, &mut AppContext) -> S,
|
||||||
{
|
{
|
||||||
cx.update_default_global(update)
|
cx.update_default_global(update)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_active_editor<S>(
|
fn update_active_editor<S>(
|
||||||
&self,
|
&self,
|
||||||
cx: &mut MutableAppContext,
|
cx: &mut AppContext,
|
||||||
update: impl FnOnce(&mut Editor, &mut ViewContext<Editor>) -> S,
|
update: impl FnOnce(&mut Editor, &mut ViewContext<Editor>) -> S,
|
||||||
) -> Option<S> {
|
) -> Option<S> {
|
||||||
self.active_editor
|
self.active_editor
|
||||||
@ -153,7 +153,7 @@ impl Vim {
|
|||||||
.map(|ae| ae.update(cx, update))
|
.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.mode = mode;
|
||||||
self.state.operator_stack.clear();
|
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.state.operator_stack.push(operator);
|
||||||
self.sync_vim_settings(cx);
|
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() {
|
if let Some(Operator::Number(current_number)) = self.active_operator() {
|
||||||
self.pop_operator(cx);
|
self.pop_operator(cx);
|
||||||
self.push_operator(Operator::Number(current_number * 10 + *number as usize), 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()
|
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");
|
.expect("Operator popped when no operator was on the stack. This likely means there is an invalid keymap config");
|
||||||
self.sync_vim_settings(cx);
|
self.sync_vim_settings(cx);
|
||||||
popped_operator
|
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;
|
let mut times = 1;
|
||||||
if let Some(Operator::Number(number)) = self.active_operator() {
|
if let Some(Operator::Number(number)) = self.active_operator() {
|
||||||
times = number;
|
times = number;
|
||||||
@ -218,7 +218,7 @@ impl Vim {
|
|||||||
times
|
times
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clear_operator(&mut self, cx: &mut MutableAppContext) {
|
fn clear_operator(&mut self, cx: &mut AppContext) {
|
||||||
self.state.operator_stack.clear();
|
self.state.operator_stack.clear();
|
||||||
self.sync_vim_settings(cx);
|
self.sync_vim_settings(cx);
|
||||||
}
|
}
|
||||||
@ -227,7 +227,7 @@ impl Vim {
|
|||||||
self.state.operator_stack.last().copied()
|
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() {
|
if text.is_empty() {
|
||||||
return;
|
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 {
|
if self.enabled != enabled {
|
||||||
self.enabled = enabled;
|
self.enabled = enabled;
|
||||||
self.state = Default::default();
|
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 state = &self.state;
|
||||||
let cursor_shape = state.cursor_shape();
|
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.update(cx, |editor, cx| {
|
||||||
editor.set_cursor_shape(CursorShape::Bar, cx);
|
editor.set_cursor_shape(CursorShape::Bar, cx);
|
||||||
editor.set_clip_at_line_ends(false, cx);
|
editor.set_clip_at_line_ends(false, cx);
|
||||||
|
@ -4,7 +4,7 @@ use collections::HashMap;
|
|||||||
use editor::{
|
use editor::{
|
||||||
display_map::ToDisplayPoint, movement, scroll::autoscroll::Autoscroll, Bias, ClipboardSelection,
|
display_map::ToDisplayPoint, movement, scroll::autoscroll::Autoscroll, Bias, ClipboardSelection,
|
||||||
};
|
};
|
||||||
use gpui::{actions, MutableAppContext, ViewContext};
|
use gpui::{actions, AppContext, ViewContext};
|
||||||
use language::{AutoindentMode, SelectionGoal};
|
use language::{AutoindentMode, SelectionGoal};
|
||||||
use workspace::Workspace;
|
use workspace::Workspace;
|
||||||
|
|
||||||
@ -18,14 +18,14 @@ use crate::{
|
|||||||
|
|
||||||
actions!(vim, [VisualDelete, VisualChange, VisualYank, VisualPaste]);
|
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(change);
|
||||||
cx.add_action(delete);
|
cx.add_action(delete);
|
||||||
cx.add_action(yank);
|
cx.add_action(yank);
|
||||||
cx.add_action(paste);
|
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(cx, |vim, cx| {
|
||||||
vim.update_active_editor(cx, |editor, cx| {
|
vim.update_active_editor(cx, |editor, cx| {
|
||||||
editor.change_selections(Some(Autoscroll::fit()), cx, |s| {
|
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| {
|
Vim::update(cx, |vim, cx| {
|
||||||
if let Operator::Object { around } = vim.pop_operator(cx) {
|
if let Operator::Object { around } = vim.pop_operator(cx) {
|
||||||
vim.update_active_editor(cx, |editor, 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(cx, |vim, cx| {
|
||||||
vim.update_active_editor(cx, |editor, cx| {
|
vim.update_active_editor(cx, |editor, cx| {
|
||||||
editor.transact(cx, |editor, cx| {
|
editor.transact(cx, |editor, cx| {
|
||||||
@ -648,7 +648,7 @@ mod test {
|
|||||||
cx.assert_state(
|
cx.assert_state(
|
||||||
indoc! {"
|
indoc! {"
|
||||||
The quick brown
|
The quick brown
|
||||||
the
|
the
|
||||||
ˇfox jumps over
|
ˇfox jumps over
|
||||||
dog"},
|
dog"},
|
||||||
Mode::Normal,
|
Mode::Normal,
|
||||||
|
@ -2,7 +2,7 @@ use fuzzy::{match_strings, StringMatch, StringMatchCandidate};
|
|||||||
use gpui::{
|
use gpui::{
|
||||||
actions,
|
actions,
|
||||||
elements::{ChildView, Element as _, Label},
|
elements::{ChildView, Element as _, Label},
|
||||||
AnyViewHandle, Entity, MutableAppContext, View, ViewContext, ViewHandle,
|
AnyViewHandle, Entity, AppContext, View, ViewContext, ViewHandle,
|
||||||
};
|
};
|
||||||
use picker::{Picker, PickerDelegate};
|
use picker::{Picker, PickerDelegate};
|
||||||
use settings::{settings_file::SettingsFile, BaseKeymap, Settings};
|
use settings::{settings_file::SettingsFile, BaseKeymap, Settings};
|
||||||
@ -16,7 +16,7 @@ pub struct BaseKeymapSelector {
|
|||||||
|
|
||||||
actions!(welcome, [ToggleBaseKeymapSelector]);
|
actions!(welcome, [ToggleBaseKeymapSelector]);
|
||||||
|
|
||||||
pub fn init(cx: &mut MutableAppContext) {
|
pub fn init(cx: &mut AppContext) {
|
||||||
Picker::<BaseKeymapSelector>::init(cx);
|
Picker::<BaseKeymapSelector>::init(cx);
|
||||||
cx.add_action({
|
cx.add_action({
|
||||||
move |workspace, _: &ToggleBaseKeymapSelector, cx| BaseKeymapSelector::toggle(workspace, cx)
|
move |workspace, _: &ToggleBaseKeymapSelector, cx| BaseKeymapSelector::toggle(workspace, cx)
|
||||||
|
@ -5,7 +5,7 @@ use std::sync::Arc;
|
|||||||
use db::kvp::KEY_VALUE_STORE;
|
use db::kvp::KEY_VALUE_STORE;
|
||||||
use gpui::{
|
use gpui::{
|
||||||
elements::{Flex, Label, ParentElement},
|
elements::{Flex, Label, ParentElement},
|
||||||
Element, ElementBox, Entity, MutableAppContext, Subscription, View, ViewContext,
|
Element, ElementBox, Entity, AppContext, Subscription, View, ViewContext,
|
||||||
};
|
};
|
||||||
use settings::{settings_file::SettingsFile, Settings};
|
use settings::{settings_file::SettingsFile, Settings};
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ use crate::base_keymap_picker::ToggleBaseKeymapSelector;
|
|||||||
|
|
||||||
pub const FIRST_OPEN: &str = "first_open";
|
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| {
|
cx.add_action(|workspace: &mut Workspace, _: &Welcome, cx| {
|
||||||
let welcome_page = cx.add_view(WelcomePage::new);
|
let welcome_page = cx.add_view(WelcomePage::new);
|
||||||
workspace.add_item(Box::new(welcome_page), cx)
|
workspace.add_item(Box::new(welcome_page), cx)
|
||||||
@ -27,7 +27,7 @@ pub fn init(cx: &mut MutableAppContext) {
|
|||||||
base_keymap_picker::init(cx);
|
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| {
|
open_new(&app_state, cx, |workspace, cx| {
|
||||||
workspace.toggle_sidebar(SidebarSide::Left, cx);
|
workspace.toggle_sidebar(SidebarSide::Left, cx);
|
||||||
let welcome_page = cx.add_view(|cx| WelcomePage::new(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
Loading…
Reference in New Issue
Block a user