From 95022ee0f95a4f97e48844c00ceb6f5ff7929fc4 Mon Sep 17 00:00:00 2001 From: JoshuaBatty Date: Mon, 8 Jan 2024 10:14:56 +1100 Subject: [PATCH] feedback --- sway-core/src/lib.rs | 4 +--- sway-lsp/src/handlers/notification.rs | 1 - sway-lsp/src/server_state.rs | 3 ++- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/sway-core/src/lib.rs b/sway-core/src/lib.rs index c6c53039366..718097127ba 100644 --- a/sway-core/src/lib.rs +++ b/sway-core/src/lib.rs @@ -616,9 +616,7 @@ pub fn compile_to_ast( // Check if we can re-use the data in the cache. if is_parse_module_cache_up_to_date(engines, &path, include_tests) { - let mut entry = query_engine - .get_programs_cache_entry(&path) - .unwrap_or_else(|| panic!("unable to find entry in cache at path {:?}", &path)); + let mut entry = query_engine.get_programs_cache_entry(&path).unwrap(); entry.programs.metrics.reused_modules += 1; let (warnings, errors) = entry.handler_data; diff --git a/sway-lsp/src/handlers/notification.rs b/sway-lsp/src/handlers/notification.rs index 6527632fbd3..087bc501926 100644 --- a/sway-lsp/src/handlers/notification.rs +++ b/sway-lsp/src/handlers/notification.rs @@ -25,7 +25,6 @@ pub async fn handle_did_open_text_document( // Otherwise, don't recompile the project when a new file in the project is opened // as the workspace is already compiled. if session.token_map().is_empty() { - // send_new_compilation_request(&state, session.clone(), &uri, None); let _ = state .cb_tx .send(TaskMessage::CompilationContext(CompilationContext { diff --git a/sway-lsp/src/server_state.rs b/sway-lsp/src/server_state.rs index 5893fbef533..e22b3d5679a 100644 --- a/sway-lsp/src/server_state.rs +++ b/sway-lsp/src/server_state.rs @@ -13,6 +13,7 @@ use forc_pkg::PackageManifestFile; use lsp_types::{Diagnostic, Url}; use parking_lot::RwLock; use std::{ + mem, path::PathBuf, sync::{ atomic::{AtomicBool, Ordering}, @@ -131,7 +132,7 @@ impl ServerState { Some(retrigger_compilation.clone()), ) { Ok(parse_result) => { - *session.engines.write() = engines_clone; + mem::swap(&mut *session.engines.write(), &mut engines_clone); session.write_parse_result(parse_result); *last_compilation_state.write() = LastCompilationState::Success; }