Skip to content

Commit

Permalink
Merge pull request #1489 from BetterThanTomorrow/fix-1299-proper-erro…
Browse files Browse the repository at this point in the history
…r-handling

Fixing #1299 - Clojure LSP not starting when offline
  • Loading branch information
PEZ authored Jan 22, 2022
2 parents fa0fe82 + d5bac3a commit 79c7f84
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 @@ -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)

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 @@ -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();
Expand Down

0 comments on commit 79c7f84

Please sign in to comment.