Skip to content

Commit d5bac3a

Browse files
author
Kevin Ahlbrecht
committed
Fixing #1299
Proper error handling on lsp version retrival without it the lsp couldn't be started even when an executable was already existing
1 parent 1784053 commit d5bac3a

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Changes to Calva.
44

55
## [Unreleased]
66
- [Add custom commands from libraries](https://github.com/BetterThanTomorrow/calva/pull/1442)
7+
- [Clojure-lsp not starting when offline](https://github.com/BetterThanTomorrow/calva/issues/1299)
78
- Workaround: [VS Code highlights characters in the output/REPL window prompt](https://github.com/BetterThanTomorrow/calva/pull/1475)
89

910
## [2.0.234] - 2022-01-16

src/lsp/download.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,14 @@ import { https } from 'follow-redirects';
77
import * as extractZip from 'extract-zip';
88

99
async function getLatestVersion(): Promise<string> {
10-
const releasesJSON = await util.fetchFromUrl('https://api.github.com/repos/clojure-lsp/clojure-lsp/releases');
11-
const releases = JSON.parse(releasesJSON);
12-
return releases[0].tag_name;
10+
try {
11+
const releasesJSON = await util.fetchFromUrl('https://api.github.com/repos/clojure-lsp/clojure-lsp/releases');
12+
console.log("loaded latest Json" + releasesJSON);
13+
const releases = JSON.parse(releasesJSON);
14+
return releases[0].tag_name;
15+
} catch (err) {
16+
return "";
17+
}
1318
}
1419

1520
function getZipFileName(platform: string): string {

src/lsp/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ async function activate(context: vscode.ExtensionContext, handler: TestTreeHandl
383383
if (userConfiguredClojureLspPath === '') {
384384
const configuredVersion: string = config.getConfig().clojureLspVersion;
385385
const downloadVersion = ['', 'latest'].includes(configuredVersion) ? await getLatestVersion() : configuredVersion;
386-
if (currentVersion !== downloadVersion) {
386+
if (currentVersion !== downloadVersion && downloadVersion !== '') {
387387
const downloadPromise = downloadClojureLsp(context.extensionPath, downloadVersion);
388388
lspStatus.text = '$(sync~spin) Downloading clojure-lsp';
389389
lspStatus.show();

0 commit comments

Comments
 (0)