-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Fix settings schema missing extension-provided LSP settings on remote #62355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
vancez
wants to merge
5
commits into
zed-industries:main
Choose a base branch
from
vancez:fix/remote-extension-schema-sync
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0426d01
Fix settings schema missing extension-provided LSP settings on remote
vancez e54d4af
Register remote clients with the extension store via Project::remote
vancez 8ddf01f
Merge branch 'main' into fix/remote-extension-schema-sync
SomeoneToIgnore b54ee48
Re-sync extensions to remote clients on reconnect
vancez 50cb47e
Serialize remote extension syncs in the loop task
vancez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,8 +4,8 @@ use anyhow::{Context as _, Result}; | |
| use client::{TypedEnvelope, proto}; | ||
| use collections::{HashMap, HashSet}; | ||
| use extension::{ | ||
| Extension, ExtensionDebugAdapterProviderProxy, ExtensionHostProxy, ExtensionLanguageProxy, | ||
| ExtensionLanguageServerProxy, ExtensionManifest, | ||
| Event, Extension, ExtensionDebugAdapterProviderProxy, ExtensionEvents, ExtensionHostProxy, | ||
| ExtensionLanguageProxy, ExtensionLanguageServerProxy, ExtensionManifest, | ||
| }; | ||
| use fs::{Fs, RemoveOptions, RenameOptions}; | ||
| use futures::future::{FutureExt as _, join_all}; | ||
|
|
@@ -85,24 +85,37 @@ impl HeadlessExtensionStore { | |
| }) | ||
| .collect(); | ||
|
|
||
| cx.spawn(async move |this, cx| { | ||
| cx.spawn(async move |store, cx| { | ||
| let mut missing = Vec::new(); | ||
| let mut extensions_changed = false; | ||
|
|
||
| for extension_id in to_remove { | ||
| log::info!("removing extension: {}", extension_id); | ||
| this.update(cx, |this, cx| this.uninstall_extension(&extension_id, cx))? | ||
| store | ||
| .update(cx, |store, cx| store.uninstall_extension(&extension_id, cx))? | ||
| .await?; | ||
| extensions_changed = true; | ||
| } | ||
|
|
||
| for extension in to_load { | ||
| if let Err(e) = Self::load_extension(this.clone(), extension.clone(), cx).await { | ||
| log::info!("failed to load extension: {}, {:#}", extension.id, e); | ||
| missing.push(extension) | ||
| } else if extension.dev { | ||
| missing.push(extension) | ||
| match Self::load_extension(store.clone(), extension.clone(), cx).await { | ||
| Ok(()) => { | ||
| extensions_changed = true; | ||
| if extension.dev { | ||
| missing.push(extension) | ||
| } | ||
| } | ||
| Err(e) => { | ||
| log::info!("failed to load extension: {}, {:#}", extension.id, e); | ||
| missing.push(extension) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if extensions_changed { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If every load fails or all are missing (e.g. on the very initial load), we would notify for nothing? |
||
| store.update(cx, |_, cx| notify_extensions_changed(cx)).ok(); | ||
| } | ||
|
|
||
| Ok(missing) | ||
| }) | ||
| } | ||
|
|
@@ -275,19 +288,24 @@ impl HeadlessExtensionStore { | |
| let path = self.extension_dir.join(&extension.id); | ||
| let fs = self.fs.clone(); | ||
|
|
||
| cx.spawn(async move |this, cx| { | ||
| cx.spawn(async move |store, cx| { | ||
| if fs.is_dir(&path).await { | ||
| this.update(cx, |this, cx| { | ||
| this.uninstall_extension(&extension.id.clone().into(), cx) | ||
| })? | ||
| .await?; | ||
| store | ||
| .update(cx, |store, cx| { | ||
| store.uninstall_extension(&extension.id.clone().into(), cx) | ||
| })? | ||
| .await?; | ||
| } | ||
|
|
||
| fs.rename(&tmp_path, &path, RenameOptions::default()) | ||
| .await | ||
| .with_context(|| format!("Failed to rename {tmp_path:?} to {path:?}"))?; | ||
|
|
||
| Self::load_extension(this, extension, cx).await | ||
| Self::load_extension(store.clone(), extension, cx).await?; | ||
|
|
||
| store.update(cx, |_, cx| notify_extensions_changed(cx)).ok(); | ||
|
|
||
| Ok(()) | ||
| }) | ||
| } | ||
|
|
||
|
|
@@ -354,3 +372,11 @@ impl HeadlessExtensionStore { | |
| Ok(proto::Ack {}) | ||
| } | ||
| } | ||
|
|
||
| fn notify_extensions_changed(cx: &mut App) { | ||
| if let Some(events) = ExtensionEvents::try_global(cx) { | ||
| events.update(cx, |this, cx| { | ||
| this.emit(Event::ExtensionsInstalledChanged, cx) | ||
| }); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.