diff --git a/CHANGELOG.md b/CHANGELOG.md index fa0d50e06..a57b2acb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Changes to Calva. ## [Unreleased] - [Continue to support -Aalias for jack-in](https://github.com/BetterThanTomorrow/calva/issues/1474) - [Add custom commands from libraries](https://github.com/BetterThanTomorrow/calva/pull/1442) +- [Clojure-lsp not starting when offline](https://github.com/BetterThanTomorrow/calva/issues/1299) - Workaround: [VS Code highlights characters in the output/REPL window prompt](https://github.com/BetterThanTomorrow/calva/pull/1475) - [Exclude REPL output window from LSP analysis](https://github.com/BetterThanTomorrow/calva/issues/1250) diff --git a/src/lsp/download.ts b/src/lsp/download.ts index 3f8804436..021c68c46 100644 --- a/src/lsp/download.ts +++ b/src/lsp/download.ts @@ -7,9 +7,14 @@ import { https } from 'follow-redirects'; import * as extractZip from 'extract-zip'; async function getLatestVersion(): Promise { - const releasesJSON = await util.fetchFromUrl('https://api.github.com/repos/clojure-lsp/clojure-lsp/releases'); - const releases = JSON.parse(releasesJSON); - return releases[0].tag_name; + try { + const releasesJSON = await util.fetchFromUrl('https://api.github.com/repos/clojure-lsp/clojure-lsp/releases'); + console.log("loaded latest Json" + releasesJSON); + const releases = JSON.parse(releasesJSON); + return releases[0].tag_name; + } catch (err) { + return ""; + } } function getZipFileName(platform: string): string { diff --git a/src/lsp/main.ts b/src/lsp/main.ts index 3ba4abef5..c4811f574 100644 --- a/src/lsp/main.ts +++ b/src/lsp/main.ts @@ -401,7 +401,7 @@ async function activate(context: vscode.ExtensionContext, handler: TestTreeHandl if (userConfiguredClojureLspPath === '') { const configuredVersion: string = config.getConfig().clojureLspVersion; const downloadVersion = ['', 'latest'].includes(configuredVersion) ? await getLatestVersion() : configuredVersion; - if (currentVersion !== downloadVersion) { + if (currentVersion !== downloadVersion && downloadVersion !== '') { const downloadPromise = downloadClojureLsp(context.extensionPath, downloadVersion); lspStatus.text = '$(sync~spin) Downloading clojure-lsp'; lspStatus.show();