Skip to content

Commit

Permalink
Fixing #1299
Browse files Browse the repository at this point in the history
Proper error handling on lsp version retrival
without it the lsp couldn't be started even when an executable was already existing
  • Loading branch information
Kevin Ahlbrecht committed Jan 19, 2022
1 parent 1784053 commit d5bac3a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions src/lsp/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@ import { https } from 'follow-redirects';
import * as extractZip from 'extract-zip';

async function getLatestVersion(): Promise<string> {
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 {
Expand Down
2 changes: 1 addition & 1 deletion src/lsp/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit d5bac3a

Please sign in to comment.