Skip to content

Commit b477e01

Browse files
committed
add version support to textDocument/publishDiagnostics
1 parent 70563f6 commit b477e01

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

pyrefly/lib/lsp/non_wasm/server.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,14 +306,16 @@ impl ServerConnection {
306306
&self,
307307
diags: SmallMap<PathBuf, Vec<Diagnostic>>,
308308
notebook_cell_urls: SmallMap<PathBuf, Url>,
309+
version_info: &HashMap<PathBuf, i32>,
309310
) {
310311
for (path, diags) in diags {
311312
if let Some(url) = notebook_cell_urls.get(&path) {
312313
self.publish_diagnostics_for_uri(url.clone(), diags, None)
313314
} else {
314315
let path = path.absolutize();
316+
let version = version_info.get(&path).copied();
315317
match Url::from_file_path(&path) {
316-
Ok(uri) => self.publish_diagnostics_for_uri(uri, diags, None),
318+
Ok(uri) => self.publish_diagnostics_for_uri(uri, diags, version),
317319
Err(_) => eprint!("Unable to convert path to uri: {path:?}"),
318320
}
319321
}
@@ -1467,8 +1469,11 @@ impl Server {
14671469
Self::append_unused_parameter_diagnostics(transaction, &handle, diagnostics);
14681470
Self::append_unused_import_diagnostics(transaction, &handle, diagnostics);
14691471
}
1470-
self.connection
1471-
.publish_diagnostics(diags, notebook_cell_urls);
1472+
self.connection.publish_diagnostics(
1473+
diags,
1474+
notebook_cell_urls,
1475+
&*self.version_info.lock(),
1476+
);
14721477
if self
14731478
.initialize_params
14741479
.capabilities

0 commit comments

Comments
 (0)