From 6acef5a7c088bcc1cdf8a64e28b8f20ddf9dcde7 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 22 Dec 2019 13:56:19 +0100 Subject: Don't fire no-op changes after files are saved to disk --- crates/ra_lsp_server/src/main_loop.rs | 10 ++++++---- crates/ra_lsp_server/src/world.rs | 6 +++--- 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'crates/ra_lsp_server') diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs index 81fd08c91..dda318e43 100644 --- a/crates/ra_lsp_server/src/main_loop.rs +++ b/crates/ra_lsp_server/src/main_loop.rs @@ -305,7 +305,6 @@ fn loop_turn( log::info!("queued count = {}", queue_count); } - let mut state_changed = false; match event { Event::Task(task) => { on_task(task, &connection.sender, &mut loop_state.pending_requests, world_state); @@ -313,7 +312,6 @@ fn loop_turn( } Event::Vfs(task) => { world_state.vfs.write().handle_task(task); - state_changed = true; } Event::Lib(lib) => { world_state.add_lib(lib); @@ -338,7 +336,6 @@ fn loop_turn( &mut loop_state.subscriptions, not, )?; - state_changed = true; } Message::Response(resp) => { let removed = loop_state.pending_responses.remove(&resp.id); @@ -349,7 +346,12 @@ fn loop_turn( }, }; - loop_state.pending_libraries.extend(world_state.process_changes()); + let mut state_changed = false; + if let Some(changes) = world_state.process_changes() { + state_changed = true; + loop_state.pending_libraries.extend(changes); + } + while loop_state.in_flight_libraries < MAX_IN_FLIGHT_LIBS && !loop_state.pending_libraries.is_empty() { diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs index 5e53b0278..79431e7e6 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs @@ -145,10 +145,10 @@ impl WorldState { /// FIXME: better API here pub fn process_changes( &mut self, - ) -> Vec<(SourceRootId, Vec<(FileId, RelativePathBuf, Arc)>)> { + ) -> Option)>)>> { let changes = self.vfs.write().commit_changes(); if changes.is_empty() { - return Vec::new(); + return None; } let mut libs = Vec::new(); let mut change = AnalysisChange::new(); @@ -182,7 +182,7 @@ impl WorldState { } } self.analysis_host.apply_change(change); - libs + Some(libs) } pub fn add_lib(&mut self, data: LibraryData) { -- cgit v1.2.3