
Because of #26562, it is now possible to subscribe to extension update events within the LSP store, where we can then update the Schemas sent to the JSON LSP resulting in dynamic updates to the auto-complete suggestions and diagnostics in settings. Notably, this means newly installed languages and (icon) themes will auto-complete correctly as soon as the extension is installed. Closes #15436 Release Notes: - Fixed an issue where autocomplete suggestions and diagnostics for languages and (icon) themes in settings would not update when the extension with which they were added was installed or uninstalled
37 lines
950 B
Rust
37 lines
950 B
Rust
use gpui::{App, AppContext as _, Context, Entity, EventEmitter, Global};
|
|
|
|
pub fn init(cx: &mut App) {
|
|
let extension_events = cx.new(ExtensionEvents::new);
|
|
cx.set_global(GlobalExtensionEvents(extension_events));
|
|
}
|
|
|
|
struct GlobalExtensionEvents(Entity<ExtensionEvents>);
|
|
|
|
impl Global for GlobalExtensionEvents {}
|
|
|
|
/// An event bus for broadcasting extension-related events throughout the app.
|
|
pub struct ExtensionEvents;
|
|
|
|
impl ExtensionEvents {
|
|
/// Returns the global [`ExtensionEvents`].
|
|
pub fn try_global(cx: &App) -> Option<Entity<Self>> {
|
|
return cx
|
|
.try_global::<GlobalExtensionEvents>()
|
|
.map(|g| g.0.clone());
|
|
}
|
|
|
|
fn new(_cx: &mut Context<Self>) -> Self {
|
|
Self
|
|
}
|
|
|
|
pub fn emit(&mut self, event: Event, cx: &mut Context<Self>) {
|
|
cx.emit(event)
|
|
}
|
|
}
|
|
|
|
#[derive(Clone)]
|
|
pub enum Event {
|
|
ExtensionsInstalledChanged,
|
|
}
|
|
|
|
impl EventEmitter<Event> for ExtensionEvents {}
|