Skip to content

Commit

Permalink
Merge pull request #2471 from akshita31/launch_config
Browse files Browse the repository at this point in the history
Adding folders with Miscellaneous Cs files as Launch Targets
  • Loading branch information
akshita31 authored Aug 28, 2018
2 parents f2e2177 + 4bd398c commit 250f028
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

* Added support for tracking opening, closing and changing of virtual documents that don't exist on disk. (PR: [#2436](https://github.com/OmniSharp/omnisharp-vscode/pull/2436)) _(Contributed by [@NTaylorMullen](https://github.com/NTaylorMullen))_

* Enabled IDE features for .cs files that are not part of a project. (PR: [#2471](https://github.com/OmniSharp/omnisharp-vscode/pull/2471), [omnisharp-roslyn#1252](https://github.com/OmniSharp/omnisharp-roslyn/pull/1252))

#### Misc

* Added a prompt to "Restart OmniSharp" when there is a change in omnisharp "path", "useGlobalMono" or "waitForDebugger" settings.(PR: [#2316](https://github.com/OmniSharp/omnisharp-vscode/pull/2316))
Expand Down
24 changes: 22 additions & 2 deletions src/omnisharp/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export function findLaunchTargets(options: Options): Thenable<LaunchTarget[]> {
}

return vscode.workspace.findFiles(
/*include*/ '{**/*.sln,**/*.csproj,**/project.json,**/*.csx,**/*.cake}',
/*include*/ '{**/*.sln,**/*.csproj,**/project.json,**/*.csx,**/*.cake,**/*.cs}',
/*exclude*/ '{**/node_modules/**,**/.git/**,**/bower_components/**}',
/*maxResults*/ options.maxProjectResults)
.then(resourcesToLaunchTargets);
Expand Down Expand Up @@ -90,7 +90,8 @@ function resourcesToLaunchTargets(resources: vscode.Uri[]): LaunchTarget[] {
hasProjectJson = false,
hasProjectJsonAtRoot = false,
hasCSX = false,
hasCake = false;
hasCake = false,
hasCs = false;

hasCsProjFiles = resources.some(isCSharpProject);

Expand Down Expand Up @@ -134,6 +135,11 @@ function resourcesToLaunchTargets(resources: vscode.Uri[]): LaunchTarget[] {
if (!hasCake && isCake(resource)) {
hasCake = true;
}

//Discover if there is any cs file
if (!hasCs && isCs(resource)) {
hasCs = true;
}
});

// Add the root folder under the following circumstances:
Expand Down Expand Up @@ -170,6 +176,16 @@ function resourcesToLaunchTargets(resources: vscode.Uri[]): LaunchTarget[] {
kind: LaunchTargetKind.Cake
});
}

if (hasCs && !hasSlnFile && !hasCsProjFiles && !hasProjectJson && !hasProjectJsonAtRoot) {
targets.push({
label: path.basename(folderPath),
description: '',
target: folderPath,
directory: folderPath,
kind: LaunchTargetKind.Folder
});
}
});

return targets.sort((a, b) => a.directory.localeCompare(b.directory));
Expand All @@ -195,6 +211,10 @@ function isCake(resource: vscode.Uri): boolean {
return /\.cake$/i.test(resource.fsPath);
}

function isCs(resource: vscode.Uri): boolean {
return /\.cs$/i.test(resource.fsPath);
}

export interface LaunchResult {
process: ChildProcess;
command: string;
Expand Down

0 comments on commit 250f028

Please sign in to comment.