@@ -279,19 +279,21 @@ export class CodeActionController extends Disposable implements IEditorContribut
279
279
return { canPreview : ! ! action . action . edit ?. edits . length } ;
280
280
} ,
281
281
onFocus : ( action : CodeActionItem | undefined ) => {
282
- // If provider contributes ranges, then highlight contributed range over diagnostic range.
283
- if ( action && action . action . ranges ) {
282
+ if ( action && action . action ) {
283
+ const ranges = action . action . ranges ;
284
+ const diagnostics = action . action . diagnostics ;
284
285
currentDecorations . clear ( ) ;
285
- const decorations : IModelDeltaDecoration [ ] = action . action . ranges . map ( range => ( { range, options : CodeActionController . DECORATION } ) ) ;
286
- currentDecorations . set ( decorations ) ;
287
- } else if ( action && action . action . diagnostics ) {
288
- currentDecorations . clear ( ) ;
289
- const decorations : IModelDeltaDecoration [ ] = action . action . diagnostics . map ( diagnostic => ( { range : diagnostic , options : CodeActionController . DECORATION } ) ) ;
290
- currentDecorations . set ( decorations ) ;
291
- const diagnostic = action . action . diagnostics [ 0 ] ;
292
- if ( diagnostic . startLineNumber && diagnostic . startColumn ) {
293
- const selectionText = this . _editor . getModel ( ) ?. getWordAtPosition ( { lineNumber : diagnostic . startLineNumber , column : diagnostic . startColumn } ) ?. word ;
294
- aria . status ( localize ( 'editingNewSelection' , "Context: {0} at line {1} and column {2}." , selectionText , diagnostic . startLineNumber , diagnostic . startColumn ) ) ;
286
+ if ( ranges && ranges . length > 0 ) {
287
+ const decorations : IModelDeltaDecoration [ ] = ranges . map ( range => ( { range, options : CodeActionController . DECORATION } ) ) ;
288
+ currentDecorations . set ( decorations ) ;
289
+ } else if ( diagnostics && diagnostics . length > 0 ) {
290
+ const decorations : IModelDeltaDecoration [ ] = diagnostics . map ( diagnostic => ( { range : diagnostic , options : CodeActionController . DECORATION } ) ) ;
291
+ currentDecorations . set ( decorations ) ;
292
+ const diagnostic = diagnostics [ 0 ] ;
293
+ if ( diagnostic . startLineNumber && diagnostic . startColumn ) {
294
+ const selectionText = this . _editor . getModel ( ) ?. getWordAtPosition ( { lineNumber : diagnostic . startLineNumber , column : diagnostic . startColumn } ) ?. word ;
295
+ aria . status ( localize ( 'editingNewSelection' , "Context: {0} at line {1} and column {2}." , selectionText , diagnostic . startLineNumber , diagnostic . startColumn ) ) ;
296
+ }
295
297
}
296
298
} else {
297
299
currentDecorations . clear ( ) ;
0 commit comments