Use UpdateGlobal accessors in more places (#11925)

This PR updates a number of instances that were previously using
`cx.update_global` to use `UpdateGlobal::update_global` instead.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-05-16 13:30:04 -04:00 committed by GitHub
parent c1e291bc96
commit 13bbaf1e18
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 66 additions and 68 deletions

View file

@ -1,8 +1,6 @@
use crate::{insert::NormalBefore, Vim, VimModeSetting};
use editor::{Editor, EditorEvent};
use gpui::{
Action, AppContext, BorrowAppContext, Entity, EntityId, View, ViewContext, WindowContext,
};
use gpui::{Action, AppContext, Entity, EntityId, UpdateGlobal, View, ViewContext, WindowContext};
use settings::{Settings, SettingsStore};
pub fn init(cx: &mut AppContext) {
@ -63,7 +61,7 @@ fn blurred(editor: View<Editor>, cx: &mut WindowContext) {
}
fn released(entity_id: EntityId, cx: &mut AppContext) {
cx.update_global(|vim: &mut Vim, _| {
Vim::update_global(cx, |vim, _cx| {
if vim
.active_editor
.as_ref()

View file

@ -1,4 +1,4 @@
use gpui::{px, size, BorrowAppContext, Context};
use gpui::{px, size, Context, UpdateGlobal};
use indoc::indoc;
use settings::SettingsStore;
use std::{
@ -196,7 +196,7 @@ impl NeovimBackedTestContext {
.await;
self.update(|cx| {
cx.update_global(|settings: &mut SettingsStore, cx| {
SettingsStore::update_global(cx, |settings, cx| {
settings.update_user_settings::<AllLanguageSettings>(cx, |settings| {
settings.defaults.soft_wrap = Some(SoftWrap::PreferredLineLength);
settings.defaults.preferred_line_length = Some(columns);

View file

@ -56,7 +56,7 @@ impl VimTestContext {
pub fn new_with_lsp(mut cx: EditorLspTestContext, enabled: bool) -> VimTestContext {
cx.update(|cx| {
cx.update_global(|store: &mut SettingsStore, cx| {
SettingsStore::update_global(cx, |store, cx| {
store.update_user_settings::<VimModeSetting>(cx, |s| *s = Some(enabled));
});
settings::KeymapFile::load_asset("keymaps/default-macos.json", cx).unwrap();
@ -104,7 +104,7 @@ impl VimTestContext {
pub fn enable_vim(&mut self) {
self.cx.update(|cx| {
cx.update_global(|store: &mut SettingsStore, cx| {
SettingsStore::update_global(cx, |store, cx| {
store.update_user_settings::<VimModeSetting>(cx, |s| *s = Some(true));
});
})
@ -112,7 +112,7 @@ impl VimTestContext {
pub fn disable_vim(&mut self) {
self.cx.update(|cx| {
cx.update_global(|store: &mut SettingsStore, cx| {
SettingsStore::update_global(cx, |store, cx| {
store.update_user_settings::<VimModeSetting>(cx, |s| *s = Some(false));
});
})

View file

@ -27,7 +27,7 @@ use editor::{
};
use gpui::{
actions, impl_actions, Action, AppContext, EntityId, FocusableView, Global, KeystrokeEvent,
Subscription, View, ViewContext, WeakView, WindowContext,
Subscription, UpdateGlobal, View, ViewContext, WeakView, WindowContext,
};
use language::{CursorShape, Point, SelectionGoal, TransactionId};
pub use mode_indicator::ModeIndicator;
@ -106,11 +106,11 @@ pub fn init(cx: &mut AppContext) {
CommandPaletteFilter::update_global(cx, |filter, _| {
filter.hide_namespace(Vim::NAMESPACE);
});
cx.update_global(|vim: &mut Vim, cx: &mut AppContext| {
Vim::update_global(cx, |vim, cx| {
vim.set_enabled(VimModeSetting::get_global(cx).0, cx)
});
cx.observe_global::<SettingsStore>(|cx| {
cx.update_global(|vim: &mut Vim, cx: &mut AppContext| {
Vim::update_global(cx, |vim, cx| {
vim.set_enabled(VimModeSetting::get_global(cx).0, cx)
});
})