Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revisit launch on Mono #1789

Merged
merged 4 commits into from
Oct 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 28 additions & 17 deletions src/omnisharp/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ export function launchOmniSharp(cwd: string, args: string[]): Promise<LaunchResu
setTimeout(function () {
resolve(result);
}, 0);
});
})
.catch(reason => reject(reason));
});
}

Expand All @@ -215,18 +216,36 @@ function launch(cwd: string, args: string[]): Promise<LaunchResult> {
args.push(`formattingOptions:indentationSize=${getConfigurationValue(globalConfig, csharpConfig, 'editor.tabSize', 4)}`);
}

if (options.path && options.useMono) {
return launchNixMono(options.path, cwd, args);
// If the user has provide a path to OmniSharp, we'll use that.
if (options.path) {
if (platformInfo.isWindows()) {
return launchWindows(options.path, cwd, args);
}

// If we're launching on macOS/Linux, we have two possibilities:
// 1. Launch using Mono
// 2. Launch process directly (e.g. a 'run' script)
return options.useMono
? launchNixMono(options.path, cwd, args)
: launchNix(options.path, cwd, args);
}

const launchPath = options.path || getLaunchPath(platformInfo);
// If the user has not provided a path, we'll use the locally-installed OmniSharp
const basePath = path.resolve(util.getExtensionPath(), '.omnisharp');

if (platformInfo.isWindows()) {
return launchWindows(launchPath, cwd, args);
}
else {
return launchNix(launchPath, cwd, args);
return launchWindows(path.join(basePath, 'OmniSharp.exe'), cwd, args);
}

// If it's possible to launch on a global Mono, we'll do that. Otherwise, run with our
// locally installed Mono runtime.
return canLaunchMono()
.then(() => {
return launchNixMono(path.join(basePath, 'omnisharp', 'OmniSharp.exe'), cwd, args);
})
.catch(_ => {
return launchNix(path.join(basePath, 'run'), cwd, args);
});
});
}

Expand All @@ -240,14 +259,6 @@ function getConfigurationValue(globalConfig: vscode.WorkspaceConfiguration, csha
return globalConfig.get(configurationPath, defaultValue);
}

function getLaunchPath(platformInfo: PlatformInformation): string {
const binPath = path.resolve(util.getExtensionPath(), '.omnisharp');

return platformInfo.isWindows()
? path.join(binPath, 'OmniSharp.exe')
: path.join(binPath, 'run');
}

function launchWindows(launchPath: string, cwd: string, args: string[]): LaunchResult {
function escapeIfNeeded(arg: string) {
const hasSpaceWithoutQuotes = /^[^"].* .*[^"]/;
Expand Down Expand Up @@ -294,8 +305,8 @@ function launchNixMono(launchPath: string, cwd: string, args: string[]): Promise
return canLaunchMono()
.then(() => {
let argsCopy = args.slice(0); // create copy of details args
argsCopy.unshift("--assembly-loader=strict");
argsCopy.unshift(launchPath);
argsCopy.unshift("--assembly-loader=strict");

let process = spawn('mono', argsCopy, {
detached: false,
Expand Down
2 changes: 2 additions & 0 deletions src/omnisharp/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,8 @@ export class OmniSharpServer {
}

private _onLineReceived(line: string) {
line = line.trim();

if (line[0] !== '{') {
this._logger.appendLine(line);
return;
Expand Down