diff options
Diffstat (limited to 'cli/lsp/language_server.rs')
-rw-r--r-- | cli/lsp/language_server.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/cli/lsp/language_server.rs b/cli/lsp/language_server.rs index 4c3ee1013..06fefcaeb 100644 --- a/cli/lsp/language_server.rs +++ b/cli/lsp/language_server.rs @@ -88,7 +88,7 @@ use crate::cache::DenoDir; use crate::cache::FastInsecureHasher; use crate::cache::GlobalHttpCache; use crate::cache::HttpCache; -use crate::cache::LocalHttpCache; +use crate::cache::LocalLspHttpCache; use crate::factory::CliFactory; use crate::file_fetcher::FileFetcher; use crate::graph_util; @@ -204,7 +204,7 @@ pub struct Inner { /// An abstraction that handles interactions with TypeScript. pub ts_server: Arc<TsServer>, /// A map of specifiers and URLs used to translate over the LSP. - pub url_map: Arc<urls::LspUrlMap>, + pub url_map: urls::LspUrlMap, } impl LanguageServer { @@ -905,16 +905,18 @@ impl Inner { self.module_registries_location = module_registries_location; // update the cache path let global_cache = Arc::new(GlobalHttpCache::new(dir.deps_folder_path())); - let cache: Arc<dyn HttpCache> = - match self.config.maybe_deno_modules_dir_path() { - Some(local_path) => { - Arc::new(LocalHttpCache::new(local_path, global_cache)) - } - None => global_cache, - }; + let maybe_local_cache = + self.config.maybe_deno_modules_dir_path().map(|local_path| { + Arc::new(LocalLspHttpCache::new(local_path, global_cache.clone())) + }); + let cache: Arc<dyn HttpCache> = maybe_local_cache + .clone() + .map(|c| c as Arc<dyn HttpCache>) + .unwrap_or(global_cache); self.deps_http_cache = cache.clone(); self.documents.set_cache(cache.clone()); self.cache_metadata.set_cache(cache); + self.url_map.set_cache(maybe_local_cache); self.maybe_global_cache_path = new_cache_path; Ok(()) } @@ -2946,6 +2948,7 @@ impl Inner { snapshot: self.snapshot(), config: self.config.snapshot(), lint_options: self.lint_options.clone(), + url_map: self.url_map.clone(), }; if let Err(err) = self.diagnostics_server.update(snapshot) { error!("Cannot update diagnostics: {}", err); |