Skip to content

Commit 93be2ab

Browse files
authored
fix(lsp): load extension settings before configuration on document open (#7764)
1 parent ef45056 commit 93be2ab

File tree

4 files changed

+23
-0
lines changed

4 files changed

+23
-0
lines changed

.changeset/swift-apples-greet.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@biomejs/biome": patch
3+
---
4+
5+
Fixed [#6589](https://github.com/biomejs/biome/issues/6589): Biome now properly loads extension settings before loading the configuration file when opening a text document in the LSP server.

crates/biome_lsp/src/handlers/text_document.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ pub(crate) async fn did_open(
7575
"Loading configuration from text_document {:?}",
7676
&project_path
7777
);
78+
if !session.has_initialized() {
79+
session.load_extension_settings().await;
80+
}
7881
let status = session
7982
.load_biome_configuration_file(ConfigurationPathHint::FromLsp(project_path), false)
8083
.await;

crates/biome_lsp/src/server.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ impl LanguageServer for LSPServer {
314314
self.session.load_extension_settings().await;
315315
self.session.load_workspace_settings(false).await;
316316

317+
self.session.set_initialized();
317318
let msg = format!("Server initialized with PID: {}", std::process::id());
318319
self.session
319320
.client

crates/biome_lsp/src/session.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ pub(crate) struct Session {
8686
/// to update the diagnostics
8787
notified_broken_configuration: AtomicBool,
8888

89+
/// Tracks whether the initialized() notification has been received
90+
initialized: AtomicBool,
91+
8992
/// Projects opened in this session, mapped from the project's root path to
9093
/// the associated project key.
9194
projects: HashMap<BiomePath, ProjectKey>,
@@ -213,6 +216,7 @@ impl Session {
213216
extension_settings: config,
214217
cancellation,
215218
notified_broken_configuration: AtomicBool::new(false),
219+
initialized: AtomicBool::new(false),
216220
service_rx,
217221
loading_operations: Default::default(),
218222
workspace_folders: Default::default(),
@@ -623,6 +627,16 @@ impl Session {
623627
self.initialize_params.get()?.client_information.as_ref()
624628
}
625629

630+
/// Mark that the initialized() notification has been received
631+
pub(crate) fn set_initialized(&self) {
632+
self.initialized.store(true, Ordering::Relaxed);
633+
}
634+
635+
/// Returns true if the initialized() notification has been received
636+
pub(crate) fn has_initialized(&self) -> bool {
637+
self.initialized.load(Ordering::Relaxed)
638+
}
639+
626640
/// This function attempts to read the `biome.json` configuration file from
627641
/// the root URI and update the workspace settings accordingly
628642
#[tracing::instrument(level = "debug", skip(self))]

0 commit comments

Comments
 (0)