diff --git a/CHANGELOG.md b/CHANGELOG.md index effbf0311..9754dfd10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Changes to Calva. ## [Unreleased] - [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) ## [2.0.234] - 2022-01-16 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 a08e95af2..f94f2ec86 100644 --- a/src/lsp/main.ts +++ b/src/lsp/main.ts @@ -383,7 +383,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();