@@ -280,17 +280,21 @@ class CodeActionOnSaveParticipant implements ITextFileSaveParticipant {
280
280
const textEditorModel = model . textEditorModel ;
281
281
const settingsOverrides = { overrideIdentifier : textEditorModel . getLanguageId ( ) , resource : textEditorModel . uri } ;
282
282
283
- // Keeping string | boolean until fully deprecating boolean options
284
- const setting = this . configurationService . getValue < { [ kind : string ] : string | boolean } | string [ ] > ( 'editor.codeActionsOnSave' , settingsOverrides ) ;
283
+ // Convert boolean values to strings
284
+ const setting = this . configurationService . getValue < { [ kind : string ] : string | boolean } > ( 'editor.codeActionsOnSave' , settingsOverrides ) ;
285
285
if ( ! setting ) {
286
286
return undefined ;
287
287
}
288
+ const convertedSetting : { [ kind : string ] : string } = { } ;
289
+ for ( const key in setting ) {
290
+ if ( typeof setting [ key ] === 'boolean' ) {
291
+ convertedSetting [ key ] = setting [ key ] ? 'explicit' : 'never' ;
292
+ } else if ( typeof setting [ key ] === 'string' ) {
293
+ convertedSetting [ key ] = setting [ key ] as string ;
294
+ }
295
+ }
288
296
289
- const settingItems : string [ ] = Array . isArray ( setting )
290
- ? setting
291
- : Object . keys ( setting ) . filter ( x => setting [ x ] ) ;
292
-
293
- const codeActionsOnSave = this . createCodeActionsOnSave ( settingItems ) ;
297
+ const codeActionsOnSave = this . createCodeActionsOnSave ( Object . keys ( convertedSetting ) ) ;
294
298
295
299
if ( ! Array . isArray ( setting ) ) {
296
300
codeActionsOnSave . sort ( ( a , b ) => {
@@ -311,29 +315,13 @@ class CodeActionOnSaveParticipant implements ITextFileSaveParticipant {
311
315
return undefined ;
312
316
}
313
317
314
- const excludedActions = Array . isArray ( setting )
315
- ? [ ]
316
- : Object . keys ( setting )
317
- . filter ( x => setting [ x ] === 'never' || false )
318
- . map ( x => new CodeActionKind ( x ) ) ;
319
-
320
- // To be depracated once boolean support is no longer available
321
- const includedActions = Array . isArray ( setting )
322
- ? [ ]
323
- : Object . keys ( setting )
324
- . filter ( x => setting [ x ] === true )
325
- . map ( x => new CodeActionKind ( x ) ) ;
318
+ const excludedActions = Object . keys ( setting )
319
+ . filter ( x => convertedSetting [ x ] === 'never' || false )
320
+ . map ( x => new CodeActionKind ( x ) ) ;
326
321
327
322
progress . report ( { message : localize ( 'codeaction' , "Quick Fixes" ) } ) ;
328
323
329
- let filteredSaveList = Array . isArray ( setting )
330
- ? [ ]
331
- : codeActionsOnSave . filter ( x => setting [ x . value ] === 'always' || ( setting [ x . value ] === 'explicit' ) && env . reason === SaveReason . EXPLICIT ) ;
332
-
333
- // To be depracated once boolean support is no longer available
334
- if ( includedActions . length && env . reason === SaveReason . EXPLICIT ) {
335
- filteredSaveList = includedActions ;
336
- }
324
+ const filteredSaveList = codeActionsOnSave . filter ( x => convertedSetting [ x . value ] === 'always' || ( convertedSetting [ x . value ] === 'explicit' ) && env . reason === SaveReason . EXPLICIT ) ;
337
325
338
326
await this . applyOnSaveActions ( textEditorModel , filteredSaveList , excludedActions , progress , token ) ;
339
327
}
0 commit comments