Skip to content

Commit

Permalink
Merge pull request #5192 from 50Wliu/users/winstonliu/server-autostar…
Browse files Browse the repository at this point in the history
…t-preferred-path-nullability

Fix nullability for autoStart preferredPath
  • Loading branch information
JoeRobich authored Apr 28, 2022
2 parents 7b1f541 + da8b747 commit 2cd2b81
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/omnisharp/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export async function activate(context: vscode.ExtensionContext, packageJSON: an
}));

if (options.autoStart) {
server.autoStart(context.workspaceState.get<string>('lastSolutionPathOrFolder'));
server.autoStart(context.workspaceState.get<string>('lastSolutionPathOrFolder', ''));
}

// stop server on deactivate
Expand Down
4 changes: 2 additions & 2 deletions src/omnisharp/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ export class OmniSharpServer {
}
}

public autoStart(preferredPath: string | undefined): Thenable<void> {
public autoStart(preferredPath: string): Thenable<void> {
const options = this.optionProvider.GetLatestOptions();
return findLaunchTargets(options).then(async launchTargets => {
// If there aren't any potential launch targets, we create file watcher and try to
Expand Down Expand Up @@ -582,7 +582,7 @@ export class OmniSharpServer {

// If there's more than one launch target, we start the server if one of the targets
// matches the preferred path.
if (preferredPath !== undefined) {
if (preferredPath.length > 0) {
const preferredLaunchTarget = launchTargets.find((a) => a.target === preferredPath);
if (preferredLaunchTarget) {
return this.restart(preferredLaunchTarget);
Expand Down

0 comments on commit 2cd2b81

Please sign in to comment.