@@ -31,37 +31,39 @@ abstract class CppConfigurationProvider implements vscode.DebugConfigurationProv
3131 * Try to add all missing attributes to the debug configuration being launched.
3232 */
3333 resolveDebugConfiguration ( folder : vscode . WorkspaceFolder | undefined , config : vscode . DebugConfiguration , token ?: vscode . CancellationToken ) : vscode . ProviderResult < vscode . DebugConfiguration > {
34- // Fail if cppvsdbg type is running on non-Windows
35- if ( config . type === 'cppvsdbg' && os . platform ( ) !== 'win32' ) {
36- vscode . window . showErrorMessage ( "Debugger of type: 'cppvsdbg' is only available on Windows. Use type: 'cppdbg' on the current OS platform." ) ;
37- return undefined ;
38- }
39-
40- // Modify WSL config for OpenDebugAD7
41- if ( os . platform ( ) === 'win32' &&
42- config . pipeTransport &&
43- config . pipeTransport . pipeProgram ) {
44- let replacedPipeProgram : string = null ;
45- const pipeProgramStr : string = config . pipeTransport . pipeProgram . toLowerCase ( ) . trim ( ) ;
46-
47- // OpenDebugAD7 is a 32-bit process. Make sure the WSL pipe transport is using the correct program.
48- replacedPipeProgram = debugUtils . ArchitectureReplacer . checkAndReplaceWSLPipeProgram ( pipeProgramStr , debugUtils . ArchType . ia32 ) ;
49-
50- // If pipeProgram does not get replaced and there is a pipeCwd, concatenate with pipeProgramStr and attempt to replace.
51- if ( ! replacedPipeProgram && ! path . isAbsolute ( pipeProgramStr ) && config . pipeTransport . pipeCwd ) {
52- const pipeCwdStr : string = config . pipeTransport . pipeCwd . toLowerCase ( ) . trim ( ) ;
53- const newPipeProgramStr : string = path . join ( pipeCwdStr , pipeProgramStr ) ;
54-
55- replacedPipeProgram = debugUtils . ArchitectureReplacer . checkAndReplaceWSLPipeProgram ( newPipeProgramStr , debugUtils . ArchType . ia32 ) ;
34+ if ( config ) {
35+ // Fail if cppvsdbg type is running on non-Windows
36+ if ( config . type === 'cppvsdbg' && os . platform ( ) !== 'win32' ) {
37+ vscode . window . showErrorMessage ( "Debugger of type: 'cppvsdbg' is only available on Windows. Use type: 'cppdbg' on the current OS platform." ) ;
38+ return undefined ;
5639 }
5740
58- if ( replacedPipeProgram ) {
59- config . pipeTransport . pipeProgram = replacedPipeProgram ;
41+ // Modify WSL config for OpenDebugAD7
42+ if ( os . platform ( ) === 'win32' &&
43+ config . pipeTransport &&
44+ config . pipeTransport . pipeProgram ) {
45+ let replacedPipeProgram : string = null ;
46+ const pipeProgramStr : string = config . pipeTransport . pipeProgram . toLowerCase ( ) . trim ( ) ;
47+
48+ // OpenDebugAD7 is a 32-bit process. Make sure the WSL pipe transport is using the correct program.
49+ replacedPipeProgram = debugUtils . ArchitectureReplacer . checkAndReplaceWSLPipeProgram ( pipeProgramStr , debugUtils . ArchType . ia32 ) ;
50+
51+ // If pipeProgram does not get replaced and there is a pipeCwd, concatenate with pipeProgramStr and attempt to replace.
52+ if ( ! replacedPipeProgram && ! path . isAbsolute ( pipeProgramStr ) && config . pipeTransport . pipeCwd ) {
53+ const pipeCwdStr : string = config . pipeTransport . pipeCwd . toLowerCase ( ) . trim ( ) ;
54+ const newPipeProgramStr : string = path . join ( pipeCwdStr , pipeProgramStr ) ;
55+
56+ replacedPipeProgram = debugUtils . ArchitectureReplacer . checkAndReplaceWSLPipeProgram ( newPipeProgramStr , debugUtils . ArchType . ia32 ) ;
57+ }
58+
59+ if ( replacedPipeProgram ) {
60+ config . pipeTransport . pipeProgram = replacedPipeProgram ;
61+ }
6062 }
6163 }
62-
63- return config ;
64- }
64+ // if config or type is not specified, return null to trigger VS Code to open a configuration file https://github.com/Microsoft/vscode/issues/54213
65+ return config && config . type ? config : null ;
66+ }
6567}
6668
6769export class CppVsDbgConfigurationProvider extends CppConfigurationProvider {
@@ -71,7 +73,7 @@ export class CppVsDbgConfigurationProvider extends CppConfigurationProvider {
7173}
7274
7375export class CppDbgConfigurationProvider extends CppConfigurationProvider {
74- public constructor ( provider : IConfigurationAssetProvider ) {
76+ public constructor ( provider : IConfigurationAssetProvider ) {
7577 super ( provider , DebuggerType . cppdbg ) ;
7678 }
7779}
@@ -101,12 +103,12 @@ abstract class DefaultConfigurationProvider implements IConfigurationAssetProvid
101103
102104 public getInitialConfigurations ( debuggerType : DebuggerType ) : any {
103105 let configurationSnippet : IConfigurationSnippet [ ] = [ ] ;
104-
106+
105107 // Only launch configurations are initial configurations
106108 this . configurations . forEach ( configuration => {
107- configurationSnippet . push ( configuration . GetLaunchConfiguration ( ) ) ;
109+ configurationSnippet . push ( configuration . GetLaunchConfiguration ( ) ) ;
108110 } ) ;
109-
111+
110112 let initialConfigurations : any = configurationSnippet . filter ( snippet => snippet . debuggerType === debuggerType && snippet . isInitialConfiguration )
111113 . map ( snippet => JSON . parse ( snippet . bodyText ) ) ;
112114
@@ -141,7 +143,7 @@ class WindowsConfigurationProvider extends DefaultConfigurationProvider {
141143 constructor ( ) {
142144 super ( ) ;
143145 this . configurations = [
144- new MIConfigurations ( this . MIMode , this . executable , this . pipeProgram , this . setupCommandsBlock ) ,
146+ new MIConfigurations ( this . MIMode , this . executable , this . pipeProgram , this . setupCommandsBlock ) ,
145147 new PipeTransportConfigurations ( this . MIMode , this . executable , this . pipeProgram , this . setupCommandsBlock ) ,
146148 new WindowsConfigurations ( this . MIMode , this . executable , this . pipeProgram , this . setupCommandsBlock ) ,
147149 new WSLConfigurations ( this . MIMode , this . executable , this . pipeProgram , this . setupCommandsBlock ) ,
@@ -157,7 +159,7 @@ class OSXConfigurationProvider extends DefaultConfigurationProvider {
157159 constructor ( ) {
158160 super ( ) ;
159161 this . configurations = [
160- new MIConfigurations ( this . MIMode , this . executable , this . pipeProgram ) ,
162+ new MIConfigurations ( this . MIMode , this . executable , this . pipeProgram ) ,
161163 ] ;
162164 }
163165}
@@ -177,7 +179,7 @@ class LinuxConfigurationProvider extends DefaultConfigurationProvider {
177179 constructor ( ) {
178180 super ( ) ;
179181 this . configurations = [
180- new MIConfigurations ( this . MIMode , this . executable , this . pipeProgram , this . setupCommandsBlock ) ,
182+ new MIConfigurations ( this . MIMode , this . executable , this . pipeProgram , this . setupCommandsBlock ) ,
181183 new PipeTransportConfigurations ( this . MIMode , this . executable , this . pipeProgram , this . setupCommandsBlock )
182184 ] ;
183185 }
@@ -220,7 +222,7 @@ export class ConfigurationSnippetProvider implements vscode.CompletionItemProvid
220222
221223 items . map ( ( item ) => {
222224 item . insertText = item . insertText + ',' ; // Add comma
223- } ) ;
225+ } ) ;
224226 }
225227
226228 return Promise . resolve ( new vscode . CompletionList ( items , true ) ) ;
0 commit comments