Merge MutableAppContext into AppContext

There may have been a good reason for the difference at some point, or I was
still learning Rust. But now it's just &mut AppContext vs &AppContext.
This commit is contained in:
Nathan Sobo
2023-04-06 15:49:03 -06:00
parent dd00966cc6
commit de9bf6dfbd
112 changed files with 882 additions and 1041 deletions
+3 -4
View File
@@ -6,8 +6,7 @@ use collections::HashMap;
use editor::Editor;
use gpui::{
actions, elements::*, impl_actions, platform::CursorStyle, Action, AnyViewHandle, AppContext,
Entity, MouseButton, MutableAppContext, RenderContext, Subscription, Task, View, ViewContext,
ViewHandle,
Entity, MouseButton, RenderContext, Subscription, Task, View, ViewContext, ViewHandle,
};
use project::search::SearchQuery;
use serde::Deserialize;
@@ -31,7 +30,7 @@ pub enum Event {
UpdateLocation,
}
pub fn init(cx: &mut MutableAppContext) {
pub fn init(cx: &mut AppContext) {
cx.add_action(BufferSearchBar::deploy);
cx.add_action(BufferSearchBar::dismiss);
cx.add_action(BufferSearchBar::focus_editor);
@@ -45,7 +44,7 @@ pub fn init(cx: &mut MutableAppContext) {
add_toggle_option_action::<ToggleRegex>(SearchOption::Regex, cx);
}
fn add_toggle_option_action<A: Action>(option: SearchOption, cx: &mut MutableAppContext) {
fn add_toggle_option_action<A: Action>(option: SearchOption, cx: &mut AppContext) {
cx.add_action(move |pane: &mut Pane, _: &A, cx: &mut ViewContext<Pane>| {
if let Some(search_bar) = pane.toolbar().read(cx).item_of_type::<BufferSearchBar>() {
if search_bar.update(cx, |search_bar, cx| search_bar.show(false, false, cx)) {
+4 -4
View File
@@ -10,8 +10,8 @@ use editor::{
use futures::StreamExt;
use gpui::{
actions, elements::*, platform::CursorStyle, Action, AnyViewHandle, AppContext, ElementBox,
Entity, ModelContext, ModelHandle, MouseButton, MutableAppContext, RenderContext, Subscription,
Task, View, ViewContext, ViewHandle, WeakModelHandle, WeakViewHandle,
Entity, ModelContext, ModelHandle, MouseButton, RenderContext, Subscription, Task, View,
ViewContext, ViewHandle, WeakModelHandle, WeakViewHandle,
};
use menu::Confirm;
use project::{search::SearchQuery, Project};
@@ -36,7 +36,7 @@ actions!(project_search, [SearchInNew, ToggleFocus]);
#[derive(Default)]
struct ActiveSearches(HashMap<WeakModelHandle<Project>, WeakViewHandle<ProjectSearchView>>);
pub fn init(cx: &mut MutableAppContext) {
pub fn init(cx: &mut AppContext) {
cx.set_global(ActiveSearches::default());
cx.add_action(ProjectSearchView::deploy);
cx.add_action(ProjectSearchBar::search);
@@ -50,7 +50,7 @@ pub fn init(cx: &mut MutableAppContext) {
add_toggle_option_action::<ToggleRegex>(SearchOption::Regex, cx);
}
fn add_toggle_option_action<A: Action>(option: SearchOption, cx: &mut MutableAppContext) {
fn add_toggle_option_action<A: Action>(option: SearchOption, cx: &mut AppContext) {
cx.add_action(move |pane: &mut Pane, _: &A, cx: &mut ViewContext<Pane>| {
if let Some(search_bar) = pane.toolbar().read(cx).item_of_type::<ProjectSearchBar>() {
if search_bar.update(cx, |search_bar, cx| {
+2 -2
View File
@@ -1,11 +1,11 @@
pub use buffer_search::BufferSearchBar;
use gpui::{actions, Action, MutableAppContext};
use gpui::{actions, Action, AppContext};
pub use project_search::{ProjectSearchBar, ProjectSearchView};
pub mod buffer_search;
pub mod project_search;
pub fn init(cx: &mut MutableAppContext) {
pub fn init(cx: &mut AppContext) {
buffer_search::init(cx);
project_search::init(cx);
}