@@ -26,6 +26,8 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
2626import { ITextModel } from 'vs/editor/common/model' ;
2727import { INotificationService , Severity } from 'vs/platform/notification/common/notification' ;
2828import { IModeService } from 'vs/editor/common/services/modeService' ;
29+ import { IStatusbarService } from 'vs/platform/statusbar/common/statusbar' ;
30+ import { ILabelService } from 'vs/platform/label/common/label' ;
2931
3032type FormattingEditProvider = DocumentFormattingEditProvider | DocumentRangeFormattingEditProvider ;
3133
@@ -41,7 +43,9 @@ class DefaultFormatter extends Disposable implements IWorkbenchContribution {
4143 @IConfigurationService private readonly _configService : IConfigurationService ,
4244 @INotificationService private readonly _notificationService : INotificationService ,
4345 @IQuickInputService private readonly _quickInputService : IQuickInputService ,
44- @IModeService private readonly _modeService : IModeService
46+ @IModeService private readonly _modeService : IModeService ,
47+ @IStatusbarService private readonly _statusbarService : IStatusbarService ,
48+ @ILabelService private readonly _labelService : ILabelService ,
4549 ) {
4650 super ( ) ;
4751 this . _register ( this . _extensionService . onDidChangeExtensions ( this . _updateConfigValues , this ) ) ;
@@ -76,7 +80,20 @@ class DefaultFormatter extends Disposable implements IWorkbenchContribution {
7680 if ( defaultFormatterId ) {
7781 // good -> formatter configured
7882 const [ defaultFormatter ] = formatter . filter ( formatter => ExtensionIdentifier . equals ( formatter . extensionId , defaultFormatterId ) ) ;
79- return defaultFormatter ; // this is the formatter or undefined
83+ if ( defaultFormatter ) {
84+ // formatter available
85+ return defaultFormatter ;
86+
87+ } else {
88+ // formatter gone
89+ const extension = await this . _extensionService . getExtension ( defaultFormatterId ) ;
90+ const label = this . _labelService . getUriLabel ( document . uri , { relative : true } ) ;
91+ const message = extension
92+ ? nls . localize ( 'miss' , "Extension '{0}' cannot format '{1}'" , extension . displayName || extension . name , label )
93+ : nls . localize ( 'gone' , "Extension '{0}' is configured as formatter but not available" , defaultFormatterId ) ;
94+ this . _statusbarService . setStatusMessage ( message , 4000 ) ;
95+ return undefined ;
96+ }
8097
8198 } else if ( formatter . length === 1 ) {
8299 // ok -> nothing configured but only one formatter available
0 commit comments