@@ -16,7 +16,7 @@ import { MessageController } from 'vs/editor/contrib/message/messageController';
1616import { IContextMenuService } from 'vs/platform/contextview/browser/contextView' ;
1717import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding' ;
1818import { CodeActionsState } from './codeActionModel' ;
19- import { CodeActionWidget } from './codeActionWidget' ;
19+ import { CodeActionWidget , CodeActionShowOptions } from './codeActionWidget' ;
2020import { LightBulbWidget } from './lightBulbWidget' ;
2121import { CodeActionAutoApply , CodeActionTrigger } from './types' ;
2222
@@ -48,7 +48,7 @@ export class CodeActionUi extends Disposable {
4848
4949 this . _lightBulbWidget = new Lazy ( ( ) => {
5050 const widget = this . _register ( new LightBulbWidget ( this . _editor , quickFixActionId , preferredFixActionId , keybindingService ) ) ;
51- this . _register ( widget . onClick ( e => this . showCodeActionList ( e . actions , e ) ) ) ;
51+ this . _register ( widget . onClick ( e => this . showCodeActionList ( e . actions , e , { includeDisabledActions : false } ) ) ) ;
5252 return widget ;
5353 } ) ;
5454 }
@@ -69,12 +69,6 @@ export class CodeActionUi extends Disposable {
6969
7070 this . _lightBulbWidget . getValue ( ) . update ( actions , newState . position ) ;
7171
72- if ( ! actions . allActions . length && newState . trigger . context ) {
73- MessageController . get ( this . _editor ) . showMessage ( newState . trigger . context . notAvailableMessage , newState . trigger . context . position ) ;
74- this . _activeCodeActions . value = actions ;
75- return ;
76- }
77-
7872 if ( newState . trigger . type === 'manual' ) {
7973 if ( newState . trigger . filter ?. include ) { // Triggered for specific scope
8074 // Check to see if we want to auto apply.
@@ -100,8 +94,18 @@ export class CodeActionUi extends Disposable {
10094 }
10195 }
10296
97+ const includeDisabledActions = ! ! newState . trigger . filter ?. include ;
98+ if ( newState . trigger . context ) {
99+ if ( ! actions . allActions . length || ! includeDisabledActions && ! actions . validActions . length ) {
100+ MessageController . get ( this . _editor ) . showMessage ( newState . trigger . context . notAvailableMessage , newState . trigger . context . position ) ;
101+ this . _activeCodeActions . value = actions ;
102+ actions . dispose ( ) ;
103+ return ;
104+ }
105+ }
106+
103107 this . _activeCodeActions . value = actions ;
104- this . _codeActionWidget . getValue ( ) . show ( actions , newState . position ) ;
108+ this . _codeActionWidget . getValue ( ) . show ( actions , newState . position , { includeDisabledActions } ) ;
105109 } else {
106110 // auto magically triggered
107111 if ( this . _codeActionWidget . getValue ( ) . isVisible ) {
@@ -141,7 +145,7 @@ export class CodeActionUi extends Disposable {
141145 return undefined ;
142146 }
143147
144- public async showCodeActionList ( actions : CodeActionSet , at : IAnchor | IPosition ) : Promise < void > {
145- this . _codeActionWidget . getValue ( ) . show ( actions , at ) ;
148+ public async showCodeActionList ( actions : CodeActionSet , at : IAnchor | IPosition , options : CodeActionShowOptions ) : Promise < void > {
149+ this . _codeActionWidget . getValue ( ) . show ( actions , at , options ) ;
146150 }
147151}
0 commit comments