@@ -13,11 +13,11 @@ import * as Telemetry from './telemetry';
1313import * as util from './common' ;
1414import * as vscode from 'vscode' ;
1515
16- import { geTemporaryCommandRegistrarInstance , initializeTemporaryCommandRegistrar } from './commands' ;
16+ import { getTemporaryCommandRegistrarInstance , initializeTemporaryCommandRegistrar } from './commands' ;
1717import { PlatformInformation } from './platform' ;
1818import { PackageManager , PackageManagerError , PackageManagerWebResponseError , IPackage } from './packageManager' ;
1919import { PersistentState } from './LanguageServer/persistentState' ;
20- import { initializeInstallationInformation , getInstallationInformationInstance , InstallationInformation , setInstallationStage } from './installationInformation' ;
20+ import { initializeInstallationInformation , getInstallationInformationInstance , InstallationInformation , setInstallationStage } from './installationInformation' ;
2121
2222const releaseNotesVersion : number = 3 ;
2323
@@ -44,15 +44,18 @@ export function deactivate(): Thenable<void> {
4444async function processRuntimeDependencies ( ) : Promise < void > {
4545 const installLockExists : boolean = await util . checkInstallLockFile ( ) ;
4646
47- // Offline Scenario: Lock file exists but package.json has not had its activationEvents rewritten.
4847 if ( installLockExists ) {
48+ // Offline Scenario: Lock file exists but package.json has not had its activationEvents rewritten.
4949 if ( util . packageJson . activationEvents && util . packageJson . activationEvents . length == 1 ) {
5050 try {
5151 await offlineInstallation ( ) ;
5252 } catch ( error ) {
5353 vscode . window . showErrorMessage ( 'The installation of the C/C++ extension failed. Please see the output window for more information.' ) ;
5454 util . getOutputChannel ( ) . show ( ) ;
5555 }
56+ // The extension have been installed and activated before.
57+ } else {
58+ await finalizeExtensionActivation ( ) ;
5659 }
5760 // No lock file, need to download and install dependencies.
5861 } else {
@@ -67,7 +70,7 @@ async function processRuntimeDependencies(): Promise<void> {
6770async function offlineInstallation ( ) : Promise < void > {
6871 setInstallationStage ( 'getPlatformInfo' ) ;
6972 const info : PlatformInformation = await PlatformInformation . GetPlatformInformation ( ) ;
70-
73+
7174 setInstallationStage ( 'makeBinariesExecutable' ) ;
7275 await makeBinariesExecutable ( ) ;
7376
@@ -84,7 +87,7 @@ async function offlineInstallation(): Promise<void> {
8487async function onlineInstallation ( ) : Promise < void > {
8588 setInstallationStage ( 'getPlatformInfo' ) ;
8689 const info : PlatformInformation = await PlatformInformation . GetPlatformInformation ( ) ;
87-
90+
8891 await downloadAndInstallPackages ( info ) ;
8992
9093 setInstallationStage ( 'makeBinariesExecutable' ) ;
@@ -156,7 +159,7 @@ function touchInstallLockFile(): Promise<void> {
156159}
157160
158161function handleError ( error : any ) : void {
159- let installationInformation : InstallationInformation = getInstallationInformationInstance ( ) ;
162+ let installationInformation : InstallationInformation = getInstallationInformationInstance ( ) ;
160163 installationInformation . hasError = true ;
161164 installationInformation . telemetryProperties [ 'stage' ] = installationInformation . stage ;
162165 let errorMessage : string ;
@@ -211,7 +214,7 @@ function handleError(error: any): void {
211214}
212215
213216function sendTelemetry ( info : PlatformInformation ) : boolean {
214- let installBlob : InstallationInformation = getInstallationInformationInstance ( ) ;
217+ let installBlob : InstallationInformation = getInstallationInformationInstance ( ) ;
215218 const success : boolean = ! installBlob . hasError ;
216219
217220 installBlob . telemetryProperties [ 'success' ] = success . toString ( ) ;
@@ -250,27 +253,31 @@ async function postInstall(info: PlatformInformation): Promise<void> {
250253 if ( ! installSuccess ) {
251254 return Promise . reject < void > ( "" ) ;
252255 } else {
253- const cpptoolsJsonFile : string = util . getExtensionFilePath ( "cpptools.json" ) ;
254-
255- try {
256- const exists : boolean = await util . checkFileExists ( cpptoolsJsonFile ) ;
257- if ( exists ) {
258- const cpptoolsString : string = await util . readFileText ( cpptoolsJsonFile ) ;
259- await cpptoolsJsonUtils . processCpptoolsJson ( cpptoolsString ) ;
260- }
261- } catch ( error ) {
262- // Ignore any cpptoolsJsonFile errors
263- }
264-
265- geTemporaryCommandRegistrarInstance ( ) . activateLanguageServer ( ) ;
266-
267256 // Notify user's if debugging may not be supported on their OS.
268257 util . checkDistro ( info ) ;
269258
270- // Redownload cpptools.json after activation so it's not blocked.
271- // It'll be used after the extension reloads.
272- return cpptoolsJsonUtils . downloadCpptoolsJsonPkg ( ) ;
259+ return finalizeExtensionActivation ( ) ;
260+ }
261+ }
262+
263+ async function finalizeExtensionActivation ( ) : Promise < void > {
264+ const cpptoolsJsonFile : string = util . getExtensionFilePath ( "cpptools.json" ) ;
265+
266+ try {
267+ const exists : boolean = await util . checkFileExists ( cpptoolsJsonFile ) ;
268+ if ( exists ) {
269+ const cpptoolsString : string = await util . readFileText ( cpptoolsJsonFile ) ;
270+ await cpptoolsJsonUtils . processCpptoolsJson ( cpptoolsString ) ;
271+ }
272+ } catch ( error ) {
273+ // Ignore any cpptoolsJsonFile errors
273274 }
275+
276+ getTemporaryCommandRegistrarInstance ( ) . activateLanguageServer ( ) ;
277+
278+ // Redownload cpptools.json after activation so it's not blocked.
279+ // It'll be used after the extension reloads.
280+ return cpptoolsJsonUtils . downloadCpptoolsJsonPkg ( ) ;
274281}
275282
276283function rewriteManifest ( ) : Promise < void > {
0 commit comments