Eliminate GPUI View, ViewContext, and WindowContext types (#22632)
There's still a bit more work to do on this, but this PR is compiling (with warnings) after eliminating the key types. When the tasks below are complete, this will be the new narrative for GPUI: - `Entity<T>` - This replaces `View<T>`/`Model<T>`. It represents a unit of state, and if `T` implements `Render`, then `Entity<T>` implements `Element`. - `&mut App` This replaces `AppContext` and represents the app. - `&mut Context<T>` This replaces `ModelContext` and derefs to `App`. It is provided by the framework when updating an entity. - `&mut Window` Broken out of `&mut WindowContext` which no longer exists. Every method that once took `&mut WindowContext` now takes `&mut Window, &mut App` and every method that took `&mut ViewContext<T>` now takes `&mut Window, &mut Context<T>` Not pictured here are the two other failed attempts. It's been quite a month! Tasks: - [x] Remove `View`, `ViewContext`, `WindowContext` and thread through `Window` - [x] [@cole-miller @mikayla-maki] Redraw window when entities change - [x] [@cole-miller @mikayla-maki] Get examples and Zed running - [x] [@cole-miller @mikayla-maki] Fix Zed rendering - [x] [@mikayla-maki] Fix todo! macros and comments - [x] Fix a bug where the editor would not be redrawn because of view caching - [x] remove publicness window.notify() and replace with `AppContext::notify` - [x] remove `observe_new_window_models`, replace with `observe_new_models` with an optional window - [x] Fix a bug where the project panel would not be redrawn because of the wrong refresh() call being used - [x] Fix the tests - [x] Fix warnings by eliminating `Window` params or using `_` - [x] Fix conflicts - [x] Simplify generic code where possible - [x] Rename types - [ ] Update docs ### issues post merge - [x] Issues switching between normal and insert mode - [x] Assistant re-rendering failure - [x] Vim test failures - [x] Mac build issue Release Notes: - N/A --------- Co-authored-by: Antonio Scandurra <me@as-cii.com> Co-authored-by: Cole Miller <cole@zed.dev> Co-authored-by: Mikayla <mikayla@zed.dev> Co-authored-by: Joseph <joseph@zed.dev> Co-authored-by: max <max@zed.dev> Co-authored-by: Michael Sloan <michael@zed.dev> Co-authored-by: Mikayla Maki <mikaylamaki@Mikaylas-MacBook-Pro.local> Co-authored-by: Mikayla <mikayla.c.maki@gmail.com> Co-authored-by: joão <joao@zed.dev>
This commit is contained in:
parent
21b4a0d50e
commit
6fca1d2b0b
648 changed files with 36248 additions and 28208 deletions
|
@ -5,9 +5,8 @@ use editor::{scroll::Autoscroll, Editor};
|
|||
use feature_flags::{FeatureFlagAppExt, PredictEditsFeatureFlag};
|
||||
use fs::Fs;
|
||||
use gpui::{
|
||||
actions, div, pulsating_between, Action, Animation, AnimationExt, AppContext,
|
||||
AsyncWindowContext, Corner, Entity, IntoElement, Model, ParentElement, Render, Subscription,
|
||||
View, ViewContext, WeakView, WindowContext,
|
||||
actions, div, pulsating_between, Action, Animation, AnimationExt, App, AsyncWindowContext,
|
||||
Corner, Entity, IntoElement, ParentElement, Render, Subscription, WeakEntity,
|
||||
};
|
||||
use language::{
|
||||
language_settings::{
|
||||
|
@ -46,8 +45,8 @@ pub struct InlineCompletionButton {
|
|||
file: Option<Arc<dyn File>>,
|
||||
inline_completion_provider: Option<Arc<dyn inline_completion::InlineCompletionProviderHandle>>,
|
||||
fs: Arc<dyn Fs>,
|
||||
workspace: WeakView<Workspace>,
|
||||
user_store: Model<UserStore>,
|
||||
workspace: WeakEntity<Workspace>,
|
||||
user_store: Entity<UserStore>,
|
||||
popover_menu_handle: PopoverMenuHandle<ContextMenu>,
|
||||
}
|
||||
|
||||
|
@ -59,7 +58,7 @@ enum SupermavenButtonStatus {
|
|||
}
|
||||
|
||||
impl Render for InlineCompletionButton {
|
||||
fn render(&mut self, cx: &mut ViewContext<Self>) -> impl IntoElement {
|
||||
fn render(&mut self, _: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
|
||||
let all_language_settings = all_language_settings(None, cx);
|
||||
|
||||
match all_language_settings.inline_completions.provider {
|
||||
|
@ -91,17 +90,18 @@ impl Render for InlineCompletionButton {
|
|||
return div().child(
|
||||
IconButton::new("copilot-error", icon)
|
||||
.icon_size(IconSize::Small)
|
||||
.on_click(cx.listener(move |_, _, cx| {
|
||||
if let Some(workspace) = cx.window_handle().downcast::<Workspace>()
|
||||
.on_click(cx.listener(move |_, _, window, cx| {
|
||||
if let Some(workspace) =
|
||||
window.window_handle().downcast::<Workspace>()
|
||||
{
|
||||
workspace
|
||||
.update(cx, |workspace, cx| {
|
||||
.update(cx, |workspace, _, cx| {
|
||||
workspace.show_toast(
|
||||
Toast::new(
|
||||
NotificationId::unique::<CopilotErrorToast>(),
|
||||
format!("Copilot can't be started: {}", e),
|
||||
)
|
||||
.on_click("Reinstall Copilot", |cx| {
|
||||
.on_click("Reinstall Copilot", |_, cx| {
|
||||
if let Some(copilot) = Copilot::global(cx) {
|
||||
copilot
|
||||
.update(cx, |copilot, cx| {
|
||||
|
@ -116,27 +116,29 @@ impl Render for InlineCompletionButton {
|
|||
.ok();
|
||||
}
|
||||
}))
|
||||
.tooltip(|cx| Tooltip::for_action("GitHub Copilot", &ToggleMenu, cx)),
|
||||
.tooltip(|window, cx| {
|
||||
Tooltip::for_action("GitHub Copilot", &ToggleMenu, window, cx)
|
||||
}),
|
||||
);
|
||||
}
|
||||
let this = cx.view().clone();
|
||||
let this = cx.model().clone();
|
||||
|
||||
div().child(
|
||||
PopoverMenu::new("copilot")
|
||||
.menu(move |cx| {
|
||||
.menu(move |window, cx| {
|
||||
Some(match status {
|
||||
Status::Authorized => {
|
||||
this.update(cx, |this, cx| this.build_copilot_context_menu(cx))
|
||||
}
|
||||
_ => this.update(cx, |this, cx| this.build_copilot_start_menu(cx)),
|
||||
Status::Authorized => this.update(cx, |this, cx| {
|
||||
this.build_copilot_context_menu(window, cx)
|
||||
}),
|
||||
_ => this.update(cx, |this, cx| {
|
||||
this.build_copilot_start_menu(window, cx)
|
||||
}),
|
||||
})
|
||||
})
|
||||
.anchor(Corner::BottomRight)
|
||||
.trigger(
|
||||
IconButton::new("copilot-icon", icon).tooltip(|cx| {
|
||||
Tooltip::for_action("GitHub Copilot", &ToggleMenu, cx)
|
||||
}),
|
||||
)
|
||||
.trigger(IconButton::new("copilot-icon", icon).tooltip(|window, cx| {
|
||||
Tooltip::for_action("GitHub Copilot", &ToggleMenu, window, cx)
|
||||
}))
|
||||
.with_handle(self.popover_menu_handle.clone()),
|
||||
)
|
||||
}
|
||||
|
@ -171,23 +173,23 @@ impl Render for InlineCompletionButton {
|
|||
let icon = status.to_icon();
|
||||
let tooltip_text = status.to_tooltip();
|
||||
let has_menu = status.has_menu();
|
||||
let this = cx.view().clone();
|
||||
let this = cx.model().clone();
|
||||
let fs = self.fs.clone();
|
||||
|
||||
return div().child(
|
||||
PopoverMenu::new("supermaven")
|
||||
.menu(move |cx| match &status {
|
||||
.menu(move |window, cx| match &status {
|
||||
SupermavenButtonStatus::NeedsActivation(activate_url) => {
|
||||
Some(ContextMenu::build(cx, |menu, _| {
|
||||
Some(ContextMenu::build(window, cx, |menu, _, _| {
|
||||
let fs = fs.clone();
|
||||
let activate_url = activate_url.clone();
|
||||
menu.entry("Sign In", None, move |cx| {
|
||||
menu.entry("Sign In", None, move |_, cx| {
|
||||
cx.open_url(activate_url.as_str())
|
||||
})
|
||||
.entry(
|
||||
"Use Copilot",
|
||||
None,
|
||||
move |cx| {
|
||||
move |_, cx| {
|
||||
set_completion_provider(
|
||||
fs.clone(),
|
||||
cx,
|
||||
|
@ -197,19 +199,26 @@ impl Render for InlineCompletionButton {
|
|||
)
|
||||
}))
|
||||
}
|
||||
SupermavenButtonStatus::Ready => Some(
|
||||
this.update(cx, |this, cx| this.build_supermaven_context_menu(cx)),
|
||||
),
|
||||
SupermavenButtonStatus::Ready => Some(this.update(cx, |this, cx| {
|
||||
this.build_supermaven_context_menu(window, cx)
|
||||
})),
|
||||
_ => None,
|
||||
})
|
||||
.anchor(Corner::BottomRight)
|
||||
.trigger(IconButton::new("supermaven-icon", icon).tooltip(move |cx| {
|
||||
if has_menu {
|
||||
Tooltip::for_action(tooltip_text.clone(), &ToggleMenu, cx)
|
||||
} else {
|
||||
Tooltip::text(tooltip_text.clone(), cx)
|
||||
}
|
||||
}))
|
||||
.trigger(IconButton::new("supermaven-icon", icon).tooltip(
|
||||
move |window, cx| {
|
||||
if has_menu {
|
||||
Tooltip::for_action(
|
||||
tooltip_text.clone(),
|
||||
&ToggleMenu,
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
} else {
|
||||
Tooltip::text(tooltip_text.clone())(window, cx)
|
||||
}
|
||||
},
|
||||
))
|
||||
.with_handle(self.popover_menu_handle.clone()),
|
||||
);
|
||||
}
|
||||
|
@ -240,29 +249,32 @@ impl Render for InlineCompletionButton {
|
|||
))
|
||||
.into_any_element(),
|
||||
)
|
||||
.tooltip(|cx| {
|
||||
.tooltip(|window, cx| {
|
||||
Tooltip::with_meta(
|
||||
"Edit Predictions",
|
||||
None,
|
||||
"Read Terms of Service",
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
})
|
||||
.on_click(cx.listener(move |_, _, cx| {
|
||||
.on_click(cx.listener(move |_, _, window, cx| {
|
||||
let user_store = user_store.clone();
|
||||
|
||||
if let Some(workspace) = workspace.upgrade() {
|
||||
ZedPredictTos::toggle(workspace, user_store, cx);
|
||||
ZedPredictTos::toggle(workspace, user_store, window, cx);
|
||||
}
|
||||
})),
|
||||
);
|
||||
}
|
||||
|
||||
let this = cx.view().clone();
|
||||
let this = cx.model().clone();
|
||||
let button = IconButton::new("zeta", IconName::ZedPredict).when(
|
||||
!self.popover_menu_handle.is_deployed(),
|
||||
|button| {
|
||||
button.tooltip(|cx| Tooltip::for_action("Edit Prediction", &ToggleMenu, cx))
|
||||
button.tooltip(|window, cx| {
|
||||
Tooltip::for_action("Edit Prediction", &ToggleMenu, window, cx)
|
||||
})
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -272,8 +284,8 @@ impl Render for InlineCompletionButton {
|
|||
.map_or(false, |provider| provider.is_refreshing(cx));
|
||||
|
||||
let mut popover_menu = PopoverMenu::new("zeta")
|
||||
.menu(move |cx| {
|
||||
Some(this.update(cx, |this, cx| this.build_zeta_context_menu(cx)))
|
||||
.menu(move |window, cx| {
|
||||
Some(this.update(cx, |this, cx| this.build_zeta_context_menu(window, cx)))
|
||||
})
|
||||
.anchor(Corner::BottomRight)
|
||||
.with_handle(self.popover_menu_handle.clone());
|
||||
|
@ -300,11 +312,11 @@ impl Render for InlineCompletionButton {
|
|||
|
||||
impl InlineCompletionButton {
|
||||
pub fn new(
|
||||
workspace: WeakView<Workspace>,
|
||||
workspace: WeakEntity<Workspace>,
|
||||
fs: Arc<dyn Fs>,
|
||||
user_store: Model<UserStore>,
|
||||
user_store: Entity<UserStore>,
|
||||
popover_menu_handle: PopoverMenuHandle<ContextMenu>,
|
||||
cx: &mut ViewContext<Self>,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Self {
|
||||
if let Some(copilot) = Copilot::global(cx) {
|
||||
cx.observe(&copilot, |_, _, cx| cx.notify()).detach()
|
||||
|
@ -326,17 +338,21 @@ impl InlineCompletionButton {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn build_copilot_start_menu(&mut self, cx: &mut ViewContext<Self>) -> View<ContextMenu> {
|
||||
pub fn build_copilot_start_menu(
|
||||
&mut self,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Entity<ContextMenu> {
|
||||
let fs = self.fs.clone();
|
||||
ContextMenu::build(cx, |menu, _| {
|
||||
ContextMenu::build(window, cx, |menu, _, _| {
|
||||
menu.entry("Sign In", None, copilot::initiate_sign_in)
|
||||
.entry("Disable Copilot", None, {
|
||||
let fs = fs.clone();
|
||||
move |cx| hide_copilot(fs.clone(), cx)
|
||||
move |_window, cx| hide_copilot(fs.clone(), cx)
|
||||
})
|
||||
.entry("Use Supermaven", None, {
|
||||
let fs = fs.clone();
|
||||
move |cx| {
|
||||
move |_window, cx| {
|
||||
set_completion_provider(
|
||||
fs.clone(),
|
||||
cx,
|
||||
|
@ -347,11 +363,7 @@ impl InlineCompletionButton {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn build_language_settings_menu(
|
||||
&self,
|
||||
mut menu: ContextMenu,
|
||||
cx: &mut WindowContext,
|
||||
) -> ContextMenu {
|
||||
pub fn build_language_settings_menu(&self, mut menu: ContextMenu, cx: &mut App) -> ContextMenu {
|
||||
let fs = self.fs.clone();
|
||||
|
||||
if let Some(language) = self.language.clone() {
|
||||
|
@ -367,7 +379,9 @@ impl InlineCompletionButton {
|
|||
language.name()
|
||||
),
|
||||
None,
|
||||
move |cx| toggle_inline_completions_for_language(language.clone(), fs.clone(), cx),
|
||||
move |_, cx| {
|
||||
toggle_inline_completions_for_language(language.clone(), fs.clone(), cx)
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -383,18 +397,19 @@ impl InlineCompletionButton {
|
|||
if path_enabled { "Hide" } else { "Show" }
|
||||
),
|
||||
None,
|
||||
move |cx| {
|
||||
if let Some(workspace) = cx.window_handle().downcast::<Workspace>() {
|
||||
if let Ok(workspace) = workspace.root_view(cx) {
|
||||
move |window, cx| {
|
||||
if let Some(workspace) = window.window_handle().downcast::<Workspace>() {
|
||||
if let Ok(workspace) = workspace.root_model(cx) {
|
||||
let workspace = workspace.downgrade();
|
||||
cx.spawn(|cx| {
|
||||
configure_disabled_globs(
|
||||
workspace,
|
||||
path_enabled.then_some(path.clone()),
|
||||
cx,
|
||||
)
|
||||
})
|
||||
.detach_and_log_err(cx);
|
||||
window
|
||||
.spawn(cx, |cx| {
|
||||
configure_disabled_globs(
|
||||
workspace,
|
||||
path_enabled.then_some(path.clone()),
|
||||
cx,
|
||||
)
|
||||
})
|
||||
.detach_and_log_err(cx);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -409,12 +424,16 @@ impl InlineCompletionButton {
|
|||
"Show Inline Completions for All Files"
|
||||
},
|
||||
None,
|
||||
move |cx| toggle_inline_completions_globally(fs.clone(), cx),
|
||||
move |_, cx| toggle_inline_completions_globally(fs.clone(), cx),
|
||||
)
|
||||
}
|
||||
|
||||
fn build_copilot_context_menu(&self, cx: &mut ViewContext<Self>) -> View<ContextMenu> {
|
||||
ContextMenu::build(cx, |menu, cx| {
|
||||
fn build_copilot_context_menu(
|
||||
&self,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Entity<ContextMenu> {
|
||||
ContextMenu::build(window, cx, |menu, _, cx| {
|
||||
self.build_language_settings_menu(menu, cx)
|
||||
.separator()
|
||||
.link(
|
||||
|
@ -428,26 +447,34 @@ impl InlineCompletionButton {
|
|||
})
|
||||
}
|
||||
|
||||
fn build_supermaven_context_menu(&self, cx: &mut ViewContext<Self>) -> View<ContextMenu> {
|
||||
ContextMenu::build(cx, |menu, cx| {
|
||||
fn build_supermaven_context_menu(
|
||||
&self,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Entity<ContextMenu> {
|
||||
ContextMenu::build(window, cx, |menu, _, cx| {
|
||||
self.build_language_settings_menu(menu, cx)
|
||||
.separator()
|
||||
.action("Sign Out", supermaven::SignOut.boxed_clone())
|
||||
})
|
||||
}
|
||||
|
||||
fn build_zeta_context_menu(&self, cx: &mut ViewContext<Self>) -> View<ContextMenu> {
|
||||
fn build_zeta_context_menu(
|
||||
&self,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Entity<ContextMenu> {
|
||||
let workspace = self.workspace.clone();
|
||||
ContextMenu::build(cx, |menu, cx| {
|
||||
ContextMenu::build(window, cx, |menu, _window, cx| {
|
||||
self.build_language_settings_menu(menu, cx)
|
||||
.separator()
|
||||
.entry(
|
||||
"Rate Completions",
|
||||
Some(RateCompletions.boxed_clone()),
|
||||
move |cx| {
|
||||
move |window, cx| {
|
||||
workspace
|
||||
.update(cx, |workspace, cx| {
|
||||
RateCompletionModal::toggle(workspace, cx)
|
||||
RateCompletionModal::toggle(workspace, window, cx)
|
||||
})
|
||||
.ok();
|
||||
},
|
||||
|
@ -455,7 +482,7 @@ impl InlineCompletionButton {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn update_enabled(&mut self, editor: View<Editor>, cx: &mut ViewContext<Self>) {
|
||||
pub fn update_enabled(&mut self, editor: Entity<Editor>, cx: &mut Context<Self>) {
|
||||
let editor = editor.read(cx);
|
||||
let snapshot = editor.buffer().read(cx).snapshot(cx);
|
||||
let suggestion_anchor = editor.selections.newest_anchor().start;
|
||||
|
@ -476,16 +503,21 @@ impl InlineCompletionButton {
|
|||
self.language = language.cloned();
|
||||
self.file = file;
|
||||
|
||||
cx.notify()
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
pub fn toggle_menu(&mut self, cx: &mut ViewContext<Self>) {
|
||||
self.popover_menu_handle.toggle(cx);
|
||||
pub fn toggle_menu(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||
self.popover_menu_handle.toggle(window, cx);
|
||||
}
|
||||
}
|
||||
|
||||
impl StatusItemView for InlineCompletionButton {
|
||||
fn set_active_pane_item(&mut self, item: Option<&dyn ItemHandle>, cx: &mut ViewContext<Self>) {
|
||||
fn set_active_pane_item(
|
||||
&mut self,
|
||||
item: Option<&dyn ItemHandle>,
|
||||
_: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if let Some(editor) = item.and_then(|item| item.act_as::<Editor>(cx)) {
|
||||
self.editor_subscription = Some((
|
||||
cx.observe(&editor, Self::update_enabled),
|
||||
|
@ -529,13 +561,13 @@ impl SupermavenButtonStatus {
|
|||
}
|
||||
|
||||
async fn configure_disabled_globs(
|
||||
workspace: WeakView<Workspace>,
|
||||
workspace: WeakEntity<Workspace>,
|
||||
path_to_disable: Option<Arc<Path>>,
|
||||
mut cx: AsyncWindowContext,
|
||||
) -> Result<()> {
|
||||
let settings_editor = workspace
|
||||
.update(&mut cx, |_, cx| {
|
||||
create_and_open_local_file(paths::settings_file(), cx, || {
|
||||
.update_in(&mut cx, |_, window, cx| {
|
||||
create_and_open_local_file(paths::settings_file(), window, cx, || {
|
||||
settings::initial_user_settings_content().as_ref().into()
|
||||
})
|
||||
})?
|
||||
|
@ -543,45 +575,47 @@ async fn configure_disabled_globs(
|
|||
.downcast::<Editor>()
|
||||
.unwrap();
|
||||
|
||||
settings_editor.downgrade().update(&mut cx, |item, cx| {
|
||||
let text = item.buffer().read(cx).snapshot(cx).text();
|
||||
settings_editor
|
||||
.downgrade()
|
||||
.update_in(&mut cx, |item, window, cx| {
|
||||
let text = item.buffer().read(cx).snapshot(cx).text();
|
||||
|
||||
let settings = cx.global::<SettingsStore>();
|
||||
let edits = settings.edits_for_update::<AllLanguageSettings>(&text, |file| {
|
||||
let copilot = file.inline_completions.get_or_insert_with(Default::default);
|
||||
let globs = copilot.disabled_globs.get_or_insert_with(|| {
|
||||
settings
|
||||
.get::<AllLanguageSettings>(None)
|
||||
.inline_completions
|
||||
.disabled_globs
|
||||
.iter()
|
||||
.map(|glob| glob.glob().to_string())
|
||||
.collect()
|
||||
let settings = cx.global::<SettingsStore>();
|
||||
let edits = settings.edits_for_update::<AllLanguageSettings>(&text, |file| {
|
||||
let copilot = file.inline_completions.get_or_insert_with(Default::default);
|
||||
let globs = copilot.disabled_globs.get_or_insert_with(|| {
|
||||
settings
|
||||
.get::<AllLanguageSettings>(None)
|
||||
.inline_completions
|
||||
.disabled_globs
|
||||
.iter()
|
||||
.map(|glob| glob.glob().to_string())
|
||||
.collect()
|
||||
});
|
||||
|
||||
if let Some(path_to_disable) = &path_to_disable {
|
||||
globs.push(path_to_disable.to_string_lossy().into_owned());
|
||||
} else {
|
||||
globs.clear();
|
||||
}
|
||||
});
|
||||
|
||||
if let Some(path_to_disable) = &path_to_disable {
|
||||
globs.push(path_to_disable.to_string_lossy().into_owned());
|
||||
} else {
|
||||
globs.clear();
|
||||
}
|
||||
});
|
||||
if !edits.is_empty() {
|
||||
item.change_selections(Some(Autoscroll::newest()), window, cx, |selections| {
|
||||
selections.select_ranges(edits.iter().map(|e| e.0.clone()));
|
||||
});
|
||||
|
||||
if !edits.is_empty() {
|
||||
item.change_selections(Some(Autoscroll::newest()), cx, |selections| {
|
||||
selections.select_ranges(edits.iter().map(|e| e.0.clone()));
|
||||
});
|
||||
|
||||
// When *enabling* a path, don't actually perform an edit, just select the range.
|
||||
if path_to_disable.is_some() {
|
||||
item.edit(edits.iter().cloned(), cx);
|
||||
// When *enabling* a path, don't actually perform an edit, just select the range.
|
||||
if path_to_disable.is_some() {
|
||||
item.edit(edits.iter().cloned(), cx);
|
||||
}
|
||||
}
|
||||
}
|
||||
})?;
|
||||
})?;
|
||||
|
||||
anyhow::Ok(())
|
||||
}
|
||||
|
||||
fn toggle_inline_completions_globally(fs: Arc<dyn Fs>, cx: &mut AppContext) {
|
||||
fn toggle_inline_completions_globally(fs: Arc<dyn Fs>, cx: &mut App) {
|
||||
let show_inline_completions =
|
||||
all_language_settings(None, cx).inline_completions_enabled(None, None, cx);
|
||||
update_settings_file::<AllLanguageSettings>(fs, cx, move |file, _| {
|
||||
|
@ -589,11 +623,7 @@ fn toggle_inline_completions_globally(fs: Arc<dyn Fs>, cx: &mut AppContext) {
|
|||
});
|
||||
}
|
||||
|
||||
fn set_completion_provider(
|
||||
fs: Arc<dyn Fs>,
|
||||
cx: &mut AppContext,
|
||||
provider: InlineCompletionProvider,
|
||||
) {
|
||||
fn set_completion_provider(fs: Arc<dyn Fs>, cx: &mut App, provider: InlineCompletionProvider) {
|
||||
update_settings_file::<AllLanguageSettings>(fs, cx, move |file, _| {
|
||||
file.features
|
||||
.get_or_insert(Default::default())
|
||||
|
@ -601,11 +631,7 @@ fn set_completion_provider(
|
|||
});
|
||||
}
|
||||
|
||||
fn toggle_inline_completions_for_language(
|
||||
language: Arc<Language>,
|
||||
fs: Arc<dyn Fs>,
|
||||
cx: &mut AppContext,
|
||||
) {
|
||||
fn toggle_inline_completions_for_language(language: Arc<Language>, fs: Arc<dyn Fs>, cx: &mut App) {
|
||||
let show_inline_completions =
|
||||
all_language_settings(None, cx).inline_completions_enabled(Some(&language), None, cx);
|
||||
update_settings_file::<AllLanguageSettings>(fs, cx, move |file, _| {
|
||||
|
@ -616,7 +642,7 @@ fn toggle_inline_completions_for_language(
|
|||
});
|
||||
}
|
||||
|
||||
fn hide_copilot(fs: Arc<dyn Fs>, cx: &mut AppContext) {
|
||||
fn hide_copilot(fs: Arc<dyn Fs>, cx: &mut App) {
|
||||
update_settings_file::<AllLanguageSettings>(fs, cx, move |file, _| {
|
||||
file.features
|
||||
.get_or_insert(Default::default())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue