@@ -42,6 +42,7 @@ let buildInfoCache: BuildInfo | null = null;
4242const taskSourceStr : string = "C/C++" ;
4343const cppInstallVsixStr : string = 'C/C++: Install vsix -- ' ;
4444let taskProvider : vscode . Disposable ;
45+ const intelliSenseDisabledError : string = "Do not activate the extension when IntelliSense is disabled." ;
4546
4647/**
4748 * activate: set up the extension for language services
@@ -150,7 +151,15 @@ export async function getBuildTasks(returnComplerPath: boolean): Promise<vscode.
150151 // for the active file, remove duplicate compiler names, then finally add the user's compilerPath setting.
151152 let compilerPaths : string [ ] ;
152153 const isWindows : boolean = os . platform ( ) === 'win32' ;
153- const activeClient : Client = getActiveClient ( ) ;
154+ let activeClient : Client ;
155+ try {
156+ activeClient = getActiveClient ( ) ;
157+ } catch ( e ) {
158+ if ( ! e || e . message !== intelliSenseDisabledError ) {
159+ console . error ( "Unknown error calling getActiveClient()." ) ;
160+ }
161+ return [ ] ; // Language service features may be disabled.
162+ }
154163 let userCompilerPath : string = await activeClient . getCompilerPath ( ) ;
155164 if ( userCompilerPath ) {
156165 userCompilerPath = userCompilerPath . trim ( ) ;
@@ -280,7 +289,7 @@ function onActivationEvent(): void {
280289
281290function realActivation ( ) : void {
282291 if ( new CppSettings ( ) . intelliSenseEngine === "Disabled" ) {
283- throw new Error ( "Do not activate the extension when IntelliSense is disabled." ) ;
292+ throw new Error ( intelliSenseDisabledError ) ;
284293 } else {
285294 console . log ( "activating extension" ) ;
286295 let checkForConflictingExtensions : PersistentState < boolean > = new PersistentState < boolean > ( "CPP." + util . packageJson . version + ".checkForConflictingExtensions" , true ) ;
0 commit comments