Skip to content

Commit 07a9cf6

Browse files
authored
Merge pull request dotnet#4780 from JoeRobich/open-first-target
Launch with first Folder or Solution target found
2 parents 1756e25 + cb4f9e6 commit 07a9cf6

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

src/observers/ProjectStatusBarObserver.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { basename, join } from 'path';
6+
import { basename } from 'path';
77
import { BaseEvent, WorkspaceInformationUpdated } from "../omnisharp/loggingEvents";
88
import { BaseStatusBarItemObserver } from './BaseStatusBarItemObserver';
99
import { EventType } from '../omnisharp/EventType';
@@ -27,22 +27,7 @@ export class ProjectStatusBarObserver extends BaseStatusBarItemObserver {
2727
let label: string;
2828
let msbuild = event.info.MsBuild;
2929
if (msbuild && msbuild.SolutionPath) {
30-
if (msbuild.SolutionPath.endsWith(".sln")) {
31-
label = basename(msbuild.SolutionPath);
32-
}
33-
else {
34-
// a project file was open, determine which project
35-
for (const project of msbuild.Projects) {
36-
// Get the project name.
37-
label = basename(project.Path);
38-
39-
// The solution path is the folder containing the open project. Combine it with the
40-
// project name and see if it matches the project's path.
41-
if (join(msbuild.SolutionPath, label) === project.Path) {
42-
break;
43-
}
44-
}
45-
}
30+
label = basename(msbuild.SolutionPath);
4631
this.SetAndShowStatusBar('$(file-directory) ' + label, 'o.pickProjectAndStart');
4732
}
4833
else {

src/omnisharp/server.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,14 @@ export class OmniSharpServer {
559559
}
560560
}
561561

562+
// To maintain previous behavior when there are mulitple targets available,
563+
// launch with first Solution or Folder target.
564+
const firstFolderOrSolutionTarget = launchTargets
565+
.find(target => target.kind == LaunchTargetKind.Folder || target.kind == LaunchTargetKind.Solution);
566+
if (firstFolderOrSolutionTarget) {
567+
return this.restart(firstFolderOrSolutionTarget);
568+
}
569+
562570
// When running integration tests, open the first launch target.
563571
if (process.env.RUNNING_INTEGRATION_TESTS === "true") {
564572
return this.restart(launchTargets[0]);

0 commit comments

Comments
 (0)