diff options
Diffstat (limited to 'crates/ra_lsp_server/src/main_loop.rs')
-rw-r--r-- | crates/ra_lsp_server/src/main_loop.rs | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 84012b99d..e087c4f7e 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs | |||
@@ -337,11 +337,34 @@ fn loop_turn( | |||
337 | loop_state.in_flight_libraries -= 1; | 337 | loop_state.in_flight_libraries -= 1; |
338 | } | 338 | } |
339 | Event::CheckWatcher(task) => match task { | 339 | Event::CheckWatcher(task) => match task { |
340 | CheckTask::Update(uri) => { | 340 | CheckTask::ClearDiagnostics => { |
341 | let cleared_files = world_state.check_watcher.state.write().clear(); | ||
342 | |||
343 | // Send updated diagnostics for each cleared file | ||
344 | for url in cleared_files { | ||
345 | let path = url.to_file_path().map_err(|()| format!("invalid uri: {}", url))?; | ||
346 | if let Some(file_id) = world_state.vfs.read().path2file(&path) { | ||
347 | let params = handlers::publish_diagnostics( | ||
348 | &world_state.snapshot(), | ||
349 | FileId(file_id.0), | ||
350 | )?; | ||
351 | let not = notification_new::<req::PublishDiagnostics>(params); | ||
352 | task_sender.send(Task::Notify(not)).unwrap(); | ||
353 | } | ||
354 | } | ||
355 | } | ||
356 | |||
357 | CheckTask::AddDiagnostic(url, diagnostic) => { | ||
358 | world_state | ||
359 | .check_watcher | ||
360 | .state | ||
361 | .write() | ||
362 | .add_diagnostic_with_fixes(url.clone(), diagnostic); | ||
363 | |||
341 | // We manually send a diagnostic update when the watcher asks | 364 | // We manually send a diagnostic update when the watcher asks |
342 | // us to, to avoid the issue of having to change the file to | 365 | // us to, to avoid the issue of having to change the file to |
343 | // receive updated diagnostics. | 366 | // receive updated diagnostics. |
344 | let path = uri.to_file_path().map_err(|()| format!("invalid uri: {}", uri))?; | 367 | let path = url.to_file_path().map_err(|()| format!("invalid uri: {}", url))?; |
345 | if let Some(file_id) = world_state.vfs.read().path2file(&path) { | 368 | if let Some(file_id) = world_state.vfs.read().path2file(&path) { |
346 | let params = | 369 | let params = |
347 | handlers::publish_diagnostics(&world_state.snapshot(), FileId(file_id.0))?; | 370 | handlers::publish_diagnostics(&world_state.snapshot(), FileId(file_id.0))?; |
@@ -349,6 +372,7 @@ fn loop_turn( | |||
349 | task_sender.send(Task::Notify(not)).unwrap(); | 372 | task_sender.send(Task::Notify(not)).unwrap(); |
350 | } | 373 | } |
351 | } | 374 | } |
375 | |||
352 | CheckTask::Status(progress) => { | 376 | CheckTask::Status(progress) => { |
353 | let params = req::ProgressParams { | 377 | let params = req::ProgressParams { |
354 | token: req::ProgressToken::String("rustAnalyzer/cargoWatcher".to_string()), | 378 | token: req::ProgressToken::String("rustAnalyzer/cargoWatcher".to_string()), |