@@ -529,7 +529,8 @@ export class RoslynLanguageServer {
529529 if ( csharpDevkitIntelliCodeExtension ) {
530530 _channel . appendLine ( 'Activating C# + C# Dev Kit + C# IntelliCode...' ) ;
531531 const csharpDevkitIntelliCodeArgs = await this . getCSharpDevkitIntelliCodeExportArgs (
532- csharpDevkitIntelliCodeExtension
532+ csharpDevkitIntelliCodeExtension ,
533+ context
533534 ) ;
534535 args = args . concat ( csharpDevkitIntelliCodeArgs ) ;
535536 } else {
@@ -822,14 +823,48 @@ export class RoslynLanguageServer {
822823 }
823824
824825 private static async getCSharpDevkitIntelliCodeExportArgs (
825- csharpDevkitIntelliCodeExtension : vscode . Extension < CSharpIntelliCodeExports >
826+ csharpDevkitIntelliCodeExtension : vscode . Extension < CSharpIntelliCodeExports > ,
827+ extensionContext : vscode . ExtensionContext
826828 ) : Promise < string [ ] > {
827- const exports = await csharpDevkitIntelliCodeExtension . activate ( ) ;
829+ try {
830+ const exports = await csharpDevkitIntelliCodeExtension . activate ( ) ;
831+
832+ const starredCompletionComponentPath = exports . components [ '@vsintellicode/starred-suggestions-csharp' ] ;
833+
834+ const csharpIntelliCodeArgs : string [ ] = [
835+ '--starredCompletionComponentPath' ,
836+ starredCompletionComponentPath ,
837+ ] ;
838+ return csharpIntelliCodeArgs ;
839+ } catch ( e ) {
840+ _channel . appendLine ( `Activation of ${ csharpDevkitIntelliCodeExtensionId } failed` ) ;
841+ _channel . appendLine ( e instanceof Error ? e . message : ( e as string ) ) ;
842+ if ( e instanceof Error && e . stack ) {
843+ _channel . appendLine ( e . stack ) ;
844+ }
845+
846+ const stateKey = 'disableIntellicodeFailedPopup' ;
847+ if ( extensionContext . globalState . get ( stateKey ) === true ) {
848+ return [ ] ;
849+ }
828850
829- const starredCompletionComponentPath = exports . components [ '@vsintellicode/starred-suggestions-csharp' ] ;
851+ const message = vscode . l10n . t (
852+ 'Intellicode completions will not be provided, {0} failed to activate.' ,
853+ csharpDevkitIntelliCodeExtensionId
854+ ) ;
855+ const showOutput = vscode . l10n . t ( 'Go to output' ) ;
856+ const suppressNotification = vscode . l10n . t ( 'Suppress notification' ) ;
857+ // Buttons are shown in right-to-left order, with a close button to the right of everything;
858+ vscode . window . showErrorMessage ( message , showOutput , suppressNotification ) . then ( ( value ) => {
859+ if ( value === showOutput ) {
860+ _channel . show ( ) ;
861+ } else if ( value == suppressNotification ) {
862+ extensionContext . globalState . update ( stateKey , true ) ;
863+ }
864+ } ) ;
830865
831- const csharpIntelliCodeArgs : string [ ] = [ '--starredCompletionComponentPath' , starredCompletionComponentPath ] ;
832- return csharpIntelliCodeArgs ;
866+ return [ ] ;
867+ }
833868 }
834869
835870 private static async setupDevKitEnvironment (
0 commit comments