diff --git a/sway-lsp/src/core/session.rs b/sway-lsp/src/core/session.rs index 7f4ed2a9153..c55869d5f66 100644 --- a/sway-lsp/src/core/session.rs +++ b/sway-lsp/src/core/session.rs @@ -477,7 +477,18 @@ pub fn parse_project( if let Some(typed) = &session.compiled_program.read().typed { session.runnables.clear(); - create_runnables(&session.runnables, typed, engines.de(), engines.se()); + let path = uri.to_file_path().unwrap(); + let program_id = program_id_from_path(&path, engines)?; + if let Some(metrics) = session.metrics.get(&program_id) { + // Check if the cached AST was returned by the compiler for the users workspace. + // If it was, then we need to use the original engines. + let engines = if metrics.reused_programs > 0 { + &*session.engines.read() + } else { + engines + }; + create_runnables(&session.runnables, typed, engines.de(), engines.se()); + } } Ok(()) } diff --git a/sway-lsp/src/handlers/notification.rs b/sway-lsp/src/handlers/notification.rs index 928262efb51..7c7dfddf7cc 100644 --- a/sway-lsp/src/handlers/notification.rs +++ b/sway-lsp/src/handlers/notification.rs @@ -111,7 +111,8 @@ pub async fn handle_did_change_text_document( session.clone(), &uri, Some(params.text_document.version), - true, + // TODO: Set this back to true once https://github.com/FuelLabs/sway/issues/6576 is fixed. + false, file_versions, ); Ok(())