+
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/stupid-socks-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@biomejs/biome": patch
---

Fixed an issue where `textDocument/codeAction` in the LSP could respond with outdated text edits after the workspace watcher observed outdated changes to the file.
51 changes: 17 additions & 34 deletions crates/biome_service/src/workspace/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,10 @@ impl WorkspaceServer {
match path.extension() {
Some("js") => {
let manifest = self.project_layout.find_node_manifest_for_path(&path);
if let Some((_, manifest)) = manifest {
if manifest.r#type == Some(PackageType::CommonJs) {
js.set_module_kind(ModuleKind::Script);
}
if let Some((_, manifest)) = manifest
&& manifest.r#type == Some(PackageType::CommonJs)
{
js.set_module_kind(ModuleKind::Script);
}
}
Some("cjs") => {
Expand Down Expand Up @@ -407,32 +407,15 @@ impl WorkspaceServer {
let opened_by_scanner = reason.is_opened_by_scanner();

// Second-pass parsing for HTML files with embedded JavaScript and CSS content
let (embedded_scripts, embedded_styles) = if let Some(file_source) = self.get_source(index)
let (embedded_scripts, embedded_styles) = if let Some(DocumentFileSource::Html(_)) =
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if-let-chains ✨

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don’t we need to update our toolchain.toml?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose it's already up-to-date, if-let-chains requires Rust 1.88.0

self.get_source(index)
&& let Some(Ok(any_parse)) = &syntax
&& let Some(html_root) = biome_html_syntax::HtmlRoot::cast(any_parse.syntax())
{
if matches!(file_source, DocumentFileSource::Html(_)) {
if let Some(Ok(any_parse)) = &syntax {
if let Some(html_root) =
biome_html_syntax::HtmlRoot::cast(any_parse.syntax().clone())
{
let mut node_cache = NodeCache::default();
let scripts = crate::file_handlers::html::extract_embedded_scripts(
&html_root,
&mut node_cache,
);
let styles = crate::file_handlers::html::parse_embedded_styles(
&html_root,
&mut node_cache,
);
(scripts, styles)
} else {
(Vec::new(), Vec::new())
}
} else {
(Vec::new(), Vec::new())
}
} else {
(Vec::new(), Vec::new())
}
let mut node_cache = NodeCache::default();
let scripts = extract_embedded_scripts(&html_root, &mut node_cache);
let styles = parse_embedded_styles(&html_root, &mut node_cache);
(scripts, styles)
} else {
(Vec::new(), Vec::new())
};
Expand Down Expand Up @@ -480,14 +463,14 @@ impl WorkspaceServer {
// content is coming from the scanner, we keep the same
// content that was already in the document. This means,
// active clients are leading over the filesystem.
let content = if document.version.is_some() && opened_by_scanner {
document.content.clone()
} else {
content.clone()
if document.version.is_some() && opened_by_scanner {
let mut doc = document.clone();
doc.opened_by_scanner = true;
return Operation::Insert(doc);
};

Operation::Insert::<Document, bool>(Document {
content,
content: content.clone(),
version,
file_source_index: index,
syntax: syntax.clone(),
Expand Down
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载