File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -125,9 +125,15 @@ export async function activate(context: vscode.ExtensionContext): Promise<CppToo
125
125
for ( let i : number = 0 ; i < vscode . workspace . workspaceFolders . length ; ++ i ) {
126
126
const config : string = path . join ( vscode . workspace . workspaceFolders [ i ] . uri . fsPath , ".vscode/c_cpp_properties.json" ) ;
127
127
if ( await util . checkFileExists ( config ) ) {
128
- const doc : vscode . TextDocument = await vscode . workspace . openTextDocument ( config ) ;
129
- void vscode . languages . setTextDocumentLanguage ( doc , "jsonc" ) ;
130
- util . setWorkspaceIsCpp ( ) ;
128
+ try {
129
+ const doc : vscode . TextDocument = await vscode . workspace . openTextDocument ( config ) ;
130
+ void vscode . languages . setTextDocumentLanguage ( doc , "jsonc" ) ;
131
+ util . setWorkspaceIsCpp ( ) ;
132
+ } catch ( err ) {
133
+ // The c_cpp_properties.json might not be openable (e.g. an executable).
134
+ // Catching the exception prevents our extension activation from failing.
135
+ // VS Code itself will report an error message.
136
+ }
131
137
}
132
138
}
133
139
}
You can’t perform that action at this time.
0 commit comments