Skip to content

Commit d77bd5f

Browse files
committed
Do not start OmniSharp during LiveShare sessions
1 parent 611b6a1 commit d77bd5f

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

src/omnisharp/launcher.ts

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ export enum LaunchTargetKind {
1717
ProjectJson,
1818
Folder,
1919
Csx,
20-
Cake
20+
Cake,
21+
LiveShare
2122
}
2223

2324
/**
@@ -31,6 +32,24 @@ export interface LaunchTarget {
3132
kind: LaunchTargetKind;
3233
}
3334

35+
export const vslsTarget: LaunchTarget = {
36+
label: "VSLS",
37+
description: "Visual Studio Live Share",
38+
directory: "",
39+
target: "",
40+
kind: LaunchTargetKind.LiveShare
41+
};
42+
43+
/** Live share scheme */
44+
export const vsls = 'vsls';
45+
46+
/*
47+
* File scheme for which OmniSharp language feature should be disabled
48+
*/
49+
export const disabledSchemes = new Set([
50+
vsls,
51+
]);
52+
3453
/**
3554
* Returns a list of potential targets on which OmniSharp can be launched.
3655
* This includes `project.json` files, `*.sln` files (if any `*.csproj` files are found), and the root folder
@@ -67,13 +86,20 @@ function resourcesToLaunchTargets(resources: vscode.Uri[]): LaunchTarget[] {
6786
// * It should be possible to choose a .sln file even when no .csproj files are found
6887
// within the root.
6988

70-
if (!Array.isArray(resources)) {
89+
if (!Array.isArray(resources) || resources.length === 0) {
7190
return [];
7291
}
7392

93+
// Since language server functionality is run on the server instance there is no need
94+
// to start OmniSharp on the LiveShare client.
95+
const localResources = resources.filter(resource => !disabledSchemes.has(resource.scheme));
96+
if (localResources.length === 0) {
97+
return [vslsTarget];
98+
}
99+
74100
let workspaceFolderToUriMap = new Map<number, vscode.Uri[]>();
75101

76-
for (let resource of resources) {
102+
for (let resource of localResources) {
77103
let folder = vscode.workspace.getWorkspaceFolder(resource);
78104
if (folder) {
79105
let buckets: vscode.Uri[];

src/omnisharp/server.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import * as utils from '../common';
1111
import * as serverUtils from '../omnisharp/utils';
1212
import { vscode, CancellationToken } from '../vscodeAdapter';
1313
import { ChildProcess, exec } from 'child_process';
14-
import { LaunchTarget, findLaunchTargets } from './launcher';
14+
import { LaunchTarget, findLaunchTargets, LaunchTargetKind } from './launcher';
1515
import { ReadLine, createInterface } from 'readline';
1616
import { Request, RequestQueueCollection } from './requestQueue';
1717
import { DelayTracker } from './delayTracker';
@@ -246,6 +246,11 @@ export class OmniSharpServer {
246246

247247
private async _start(launchTarget: LaunchTarget, options: Options): Promise<void> {
248248

249+
if (launchTarget.kind === LaunchTargetKind.LiveShare) {
250+
this.eventStream.post(new ObservableEvents.OmnisharpServerMessage("During Live Share sessions language services are provided by the Live Share server."));
251+
return;
252+
}
253+
249254
let disposables = new CompositeDisposable();
250255

251256
disposables.add(this.onServerError(err =>

0 commit comments

Comments
 (0)