From 7bf267c197fc6a5cbafa0e72992b1cc7629ff989 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Mon, 11 Dec 2023 16:59:09 +0100 Subject: perf(lsp): simplify some of the startup code (#21538) Remove some dead code in "99_main_compiler.js". Eagerly start the LSP TSC host, it was adding some not needed complexity around the TSC thread code. --- cli/lsp/tsc.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'cli/lsp') diff --git a/cli/lsp/tsc.rs b/cli/lsp/tsc.rs index b4f4d52c7..594ef02a2 100644 --- a/cli/lsp/tsc.rs +++ b/cli/lsp/tsc.rs @@ -226,13 +226,9 @@ impl TsServer { let runtime = create_basic_runtime(); runtime.block_on(async { - let mut started = false; + start_tsc(&mut ts_runtime, false).unwrap(); + while let Some((req, state_snapshot, tx, token)) = rx.recv().await { - if !started { - // TODO(@kitsonk) need to reflect the debug state of the lsp here - start(&mut ts_runtime, false).unwrap(); - started = true; - } let value = request(&mut ts_runtime, state_snapshot, req, token.clone()); let was_sent = tx.send(value).is_ok(); @@ -3778,6 +3774,8 @@ impl TscSpecifierMap { } } +// TODO(bartlomieju): we have similar struct in `cli/tsc/mod.rs` - maybe at least change +// the name of the struct to avoid confusion? struct State { last_id: usize, performance: Arc, @@ -4057,7 +4055,7 @@ deno_core::extension!(deno_tsc, /// Instruct a language server runtime to start the language server and provide /// it with a minimal bootstrap configuration. -fn start(runtime: &mut JsRuntime, debug: bool) -> Result<(), AnyError> { +fn start_tsc(runtime: &mut JsRuntime, debug: bool) -> Result<(), AnyError> { let init_config = json!({ "debug": debug }); let init_src = format!("globalThis.serverInit({init_config});"); -- cgit v1.2.3