From 3a94a006aa1b1e61f7f8ba1375433eefd82ea112 Mon Sep 17 00:00:00 2001 From: Ravi Chande Date: Wed, 29 May 2019 14:23:20 -0700 Subject: [PATCH] Pass a semicolon-delimited list of files excluded from VS Code. (#2171) Pass Files.Exclude to omnisharp --- src/omnisharp/options.ts | 24 ++++++++++++++++++++++-- src/omnisharp/server.ts | 7 ++++++- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/omnisharp/options.ts b/src/omnisharp/options.ts index 611abc411..18062a708 100644 --- a/src/omnisharp/options.ts +++ b/src/omnisharp/options.ts @@ -29,7 +29,10 @@ export class Options { public razorPluginPath?: string, public defaultLaunchSolution?: string, public monoPath?: string, - public maxProjectFileCountForDiagnosticAnalysis?: number | null) { } + public excludePaths?: string[], + public maxProjectFileCountForDiagnosticAnalysis?: number | null) + { + } public static Read(vscode: vscode): Options { // Extra effort is taken below to ensure that legacy versions of options @@ -84,6 +87,22 @@ export class Options { const maxProjectFileCountForDiagnosticAnalysis = csharpConfig.get('maxProjectFileCountForDiagnosticAnalysis', 1000); + let workspaceConfig = vscode.workspace.getConfiguration(); + let excludePaths = []; + if (workspaceConfig) + { + let excludeFilesOption = workspaceConfig.get<{ [i: string]: boolean }>('files.exclude'); + if (excludeFilesOption) + { + for (let field in excludeFilesOption) { + if (excludeFilesOption[field]) { + excludePaths.push(field); + } + } + } + } + + return new Options( path, useGlobalMono, @@ -107,7 +126,8 @@ export class Options { razorPluginPath, defaultLaunchSolution, monoPath, - maxProjectFileCountForDiagnosticAnalysis, + excludePaths, + maxProjectFileCountForDiagnosticAnalysis ); } diff --git a/src/omnisharp/server.ts b/src/omnisharp/server.ts index 042f6287a..6d1506bff 100644 --- a/src/omnisharp/server.ts +++ b/src/omnisharp/server.ts @@ -323,6 +323,11 @@ export class OmniSharpServer { args.push('--debug'); } + for (let i = 0; i < options.excludePaths.length; i++) + { + args.push(`FileOptions:SystemExcludeSearchPatterns:${i}=${options.excludePaths[i]}`); + } + if (options.enableMsBuildLoadProjectsOnDemand === true) { args.push('MsBuild:LoadProjectsOnDemand=true'); } @@ -356,7 +361,7 @@ export class OmniSharpServer { } this._serverProcess = launchResult.process; - this._delayTrackers = {}; + this._delayTrackers = {}; await this._doConnect(options); this._setState(ServerState.Started);