Skip to content

Commit

Permalink
Add useLiveShare setting, default disabled
Browse files Browse the repository at this point in the history
Workaround for microsoft/live-share#4551
Fixes #1569
Fixes #1629
  • Loading branch information
PEZ committed Mar 26, 2022
1 parent 12f1baa commit 0edca35
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Changes to Calva.

## [Unreleased]
- [Add setting for enabling LiveShare support](https://github.com/BetterThanTomorrow/calva/issues/1629)

## [2.0.258] - 2022-03-25
- Fix: [Connect fails when there is no project file (deps.edn, etc)](https://github.com/BetterThanTomorrow/calva/issues/1613)
Expand Down
3 changes: 3 additions & 0 deletions docs/site/live-share.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ REPL. When using Live Share, Calva allows the host to share the REPL with guests
as well. If you use any of the supported configuration, this will be pretty much
automatic.

!!! Note "You need to enable the LiveShare support"
Due to [an issue in the LiveShare API](https://github.com/MicrosoftDocs/live-share/issues/4551), for some users, this feature stops Calva from connecting the REPL. Therefore the support is disabled by default. The setting is `calva.useLiveShare`.

This is what a typical scenario looks like:

1. **The host** jacks-in.
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,11 @@
"type": "object",
"title": "Calva",
"properties": {
"calva.useLiveShare": {
"type": "boolean",
"markdownDescription": "Enable support for LiveShare. Currently defaults to false, because of [ive-share/issues/4551](https://github.com/MicrosoftDocs/live-share/issues/4551). This issue makes Calva fail to connect to a REPL for some users.",
"default": false
},
"calva.useTestExplorer": {
"type": "boolean",
"description": "Enable experimental support for the VSCode Test Explorer",
Expand Down
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ function getConfig() {
},
enableClojureLspOnStart: configOptions.get<boolean>('enableClojureLspOnStart'),
projectRootsSearchExclude: configOptions.get<string[]>('projectRootsSearchExclude', []),
useLiveShare: configOptions.get<boolean>('useLiveShare'),
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { keywordize } from './util/string';
import { initializeDebugger } from './debugger/calva-debug';
import * as outputWindow from './results-output/results-doc';
import { evaluateInOutputWindow } from './evaluate';
import * as liveShareSupport from './liveShareSupport';
import * as liveShareSupport from './live-share';
import * as calvaDebug from './debugger/calva-debug';
import { setStateValue, getStateValue } from '../out/cljs-lib/cljs-lib';
import * as replSession from './nrepl/repl-session';
Expand Down
7 changes: 6 additions & 1 deletion src/liveShareSupport.ts → src/live-share.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Disposable } from 'vscode';
import * as vsls from 'vsls';
import * as config from './config';

// Keeps hold of the LiveShare API instance, so that it is requested only once.
let liveShare: vsls.LiveShare = null;
Expand All @@ -16,7 +17,11 @@ export async function setupLiveShareListener() {
return;
}

liveShare = await vsls.getApi();
// Due to https://github.com/MicrosoftDocs/live-share/issues/4551
// this is only done if the user enables LiveShare support in settings
if (config.getConfig().useLiveShare) {
liveShare = await vsls.getApi();
}

if (liveShare) {
liveShareListener = liveShare.onDidChangeSession(async (e: vsls.SessionChangeEvent) => {
Expand Down
2 changes: 1 addition & 1 deletion src/nrepl/jack-in.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { askForConnectSequence, ReplConnectSequence, CljsTypes } from './connect
import * as projectTypes from './project-types';
import * as outputWindow from '../results-output/results-doc';
import { JackInTerminal, JackInTerminalOptions, createCommandLine } from './jack-in-terminal';
import * as liveShareSupport from '../liveShareSupport';
import * as liveShareSupport from '../live-share';
import { getConfig } from '../config';

let jackInPTY: JackInTerminal = undefined;
Expand Down

0 comments on commit 0edca35

Please sign in to comment.