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

Launch with first Folder or Solution target found #4780

Merged
merged 3 commits into from
Sep 24, 2021
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
19 changes: 2 additions & 17 deletions src/observers/ProjectStatusBarObserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { basename, join } from 'path';
import { basename } from 'path';
import { BaseEvent, WorkspaceInformationUpdated } from "../omnisharp/loggingEvents";
import { BaseStatusBarItemObserver } from './BaseStatusBarItemObserver';
import { EventType } from '../omnisharp/EventType';
Expand All @@ -27,22 +27,7 @@ export class ProjectStatusBarObserver extends BaseStatusBarItemObserver {
let label: string;
let msbuild = event.info.MsBuild;
if (msbuild && msbuild.SolutionPath) {
if (msbuild.SolutionPath.endsWith(".sln")) {
label = basename(msbuild.SolutionPath);
}
else {
// a project file was open, determine which project
for (const project of msbuild.Projects) {
// Get the project name.
label = basename(project.Path);

// The solution path is the folder containing the open project. Combine it with the
// project name and see if it matches the project's path.
if (join(msbuild.SolutionPath, label) === project.Path) {
break;
}
}
}
label = basename(msbuild.SolutionPath);
this.SetAndShowStatusBar('$(file-directory) ' + label, 'o.pickProjectAndStart');
}
else {
Expand Down
8 changes: 8 additions & 0 deletions src/omnisharp/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,14 @@ export class OmniSharpServer {
}
}

// To maintain previous behavior when there are mulitple targets available,
// launch with first Solution or Folder target.
const firstFolderOrSolutionTarget = launchTargets
.find(target => target.kind == LaunchTargetKind.Folder || target.kind == LaunchTargetKind.Solution);
if (firstFolderOrSolutionTarget) {
return this.restart(firstFolderOrSolutionTarget);
}

// When running integration tests, open the first launch target.
if (process.env.RUNNING_INTEGRATION_TESTS === "true") {
return this.restart(launchTargets[0]);
Expand Down