fix(lsp): use cached registry config when offline (#34723)
When editing `deno.json` (or import specifiers), the LSP fetches
`https://deno.land/.well-known/deno-import-intellisense.json` to power
autocompletion. If that fetch fails — for example when the user is
offline — the previous behavior was to cache an empty file and surface
an error, so completions stopped working entirely, even if a valid
registry config had already been fetched in an earlier (online) session.
This was reported in #23898:
> Was somewhere remote the past day where I had no internet connection.
I noticed that the LSP isn't able to provide autocompletions in
`deno.json` without an active connection.
## Fix
In `ModuleRegistry::fetch_config`, when the remote fetch fails, fall
back to the previously cached configuration via `fetch_cached_remote`
(which reads the cache regardless of its freshness / `cache-control`
headers). This means that once the config has been fetched once,
completions keep working offline.
The empty-sentinel file (cached for a week to avoid repeatedly hitting
an unreachable/invalid registry) is now only written when there is no
usable cached config to fall back to — so a previously-cached good
config is no longer clobbered by an empty file on a transient network
failure.
## Test
Adds `test_registry_config_offline_fallback`: it seeds the HTTP cache
with a valid config carrying a `max-age=0` header (forcing
`RespectHeaders` to revalidate) pointed at a dead port, then asserts
that `enable()` still loads the config from cache despite the failed
fetch.
```
test result: ok. 10 passed; 0 failed; ... (cli/lsp/registries.rs tests)
```
Closes #23898
Closes denoland/divybot#426
---------
Co-authored-by: divybot <divybot@users.noreply.github.com>
Co-authored-by: Divy Srivastava <me@littledivy.com>