4
4
*--------------------------------------------------------------------------------------------*/
5
5
6
6
import * as dom from 'vs/base/browser/dom' ;
7
+ import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar' ;
8
+ import 'vs/base/browser/ui/codicons/codiconStyles' ; // The codicon symbol styles are defined here and must be loaded
7
9
import { IAnchor } from 'vs/base/browser/ui/contextview/contextview' ;
8
10
import { IListEvent , IListMouseEvent , IListRenderer } from 'vs/base/browser/ui/list/list' ;
9
11
import { List } from 'vs/base/browser/ui/list/listWidget' ;
10
12
import { Action , IAction , Separator } from 'vs/base/common/actions' ;
13
+ import { Codicon } from 'vs/base/common/codicons' ;
11
14
import { canceled } from 'vs/base/common/errors' ;
12
15
import { ResolvedKeybinding } from 'vs/base/common/keybindings' ;
13
16
import { Lazy } from 'vs/base/common/lazy' ;
14
- import { Disposable , MutableDisposable , IDisposable , DisposableStore } from 'vs/base/common/lifecycle' ;
17
+ import { Disposable , DisposableStore , IDisposable , MutableDisposable } from 'vs/base/common/lifecycle' ;
15
18
import 'vs/css!./media/action' ;
16
19
import { ICodeEditor } from 'vs/editor/browser/editorBrowser' ;
17
- import { EditorOption } from 'vs/editor/common/config/editorOptions' ;
18
20
import { IPosition , Position } from 'vs/editor/common/core/position' ;
19
21
import { IEditorContribution , ScrollType } from 'vs/editor/common/editorCommon' ;
20
22
import { CodeAction , Command } from 'vs/editor/common/languages' ;
21
23
import { ITextModel } from 'vs/editor/common/model' ;
22
24
import { ILanguageFeaturesService } from 'vs/editor/common/services/languageFeatures' ;
23
25
import { codeActionCommandId , CodeActionItem , CodeActionSet , fixAllCommandId , organizeImportsCommandId , refactorCommandId , sourceActionCommandId } from 'vs/editor/contrib/codeAction/browser/codeAction' ;
24
26
import { CodeActionAutoApply , CodeActionCommandArgs , CodeActionKind , CodeActionTrigger , CodeActionTriggerSource } from 'vs/editor/contrib/codeAction/browser/types' ;
27
+ import 'vs/editor/contrib/symbolIcons/browser/symbolIcons' ; // The codicon symbol colors are defined here and must be loaded to get colors
25
28
import { localize } from 'vs/nls' ;
26
29
import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
27
30
import { IContextKey , IContextKeyService , RawContextKey } from 'vs/platform/contextkey/common/contextkey' ;
28
- import { IContextMenuService , IContextViewService } from 'vs/platform/contextview/browser/contextView' ;
31
+ import { IContextViewService } from 'vs/platform/contextview/browser/contextView' ;
29
32
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding' ;
30
33
import { ResolvedKeybindingItem } from 'vs/platform/keybinding/common/resolvedKeybindingItem' ;
31
34
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry' ;
32
35
import { IThemeService } from 'vs/platform/theme/common/themeService' ;
33
- import 'vs/base/browser/ui/codicons/codiconStyles' ; // The codicon symbol styles are defined here and must be loaded
34
- import 'vs/editor/contrib/symbolIcons/browser/symbolIcons' ; // The codicon symbol colors are defined here and must be loaded to get colors
35
- import { Codicon } from 'vs/base/common/codicons' ;
36
- import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar' ;
37
36
38
37
export const Context = {
39
38
Visible : new RawContextKey < boolean > ( 'codeActionMenuVisible' , false , localize ( 'codeActionMenuVisible' , "Whether the code action list widget is visible" ) )
@@ -309,12 +308,9 @@ export class CodeActionMenu extends Disposable implements IEditorContribution {
309
308
return editor . getContribution < CodeActionMenu > ( CodeActionMenu . ID ) ;
310
309
}
311
310
312
- private readonly _keybindingResolver : CodeActionKeybindingResolver ;
313
-
314
311
constructor (
315
312
private readonly _editor : ICodeEditor ,
316
313
private readonly _delegate : CodeActionWidgetDelegate ,
317
- @IContextMenuService private readonly _contextMenuService : IContextMenuService ,
318
314
@IKeybindingService private readonly keybindingService : IKeybindingService ,
319
315
@ILanguageFeaturesService private readonly _languageFeaturesService : ILanguageFeaturesService ,
320
316
@ITelemetryService private readonly _telemetryService : ITelemetryService ,
@@ -325,31 +321,18 @@ export class CodeActionMenu extends Disposable implements IEditorContribution {
325
321
) {
326
322
super ( ) ;
327
323
328
- this . _keybindingResolver = new CodeActionKeybindingResolver ( {
329
- getKeybindings : ( ) => keybindingService . getKeybindings ( )
330
- } ) ;
331
-
332
324
this . _ctxMenuWidgetVisible = Context . Visible . bindTo ( this . _contextKeyService ) ;
333
325
}
334
326
335
327
get isVisible ( ) : boolean {
336
328
return this . _visible ;
337
329
}
338
330
339
- /**
340
- * Checks if the settings have enabled the new code action widget.
341
- */
342
- private isCodeActionWidgetEnabled ( model : ITextModel ) : boolean {
343
- return this . _configurationService . getValue ( 'editor.useCustomCodeActionMenu' , {
344
- resource : model . uri
345
- } ) ;
346
- }
347
-
348
331
/**
349
332
* Checks if the setting has disabled/enabled headers in the code action widget.
350
333
*/
351
334
private isCodeActionWidgetHeadersShown ( model : ITextModel ) : boolean {
352
- return this . _configurationService . getValue ( 'editor.customCodeActionMenu .showHeaders' , {
335
+ return this . _configurationService . getValue ( 'editor.codeActionWidget .showHeaders' , {
353
336
resource : model . uri
354
337
} ) ;
355
338
}
@@ -810,28 +793,7 @@ export class CodeActionMenu extends Disposable implements IEditorContribution {
810
793
const anchor = Position . isIPosition ( at ) ? this . _toCoords ( at ) : at || { x : 0 , y : 0 } ;
811
794
812
795
const params = < ICodeActionMenuParameters > { options, trigger, codeActions, anchor, menuActions, showDisabled : true , visible : this . _visible , menuObj : this } ;
813
- const resolver = this . _keybindingResolver . getResolver ( ) ;
814
-
815
- const useShadowDOM = this . _editor . getOption ( EditorOption . useShadowDOM ) ;
816
-
817
-
818
- if ( this . isCodeActionWidgetEnabled ( model ) ) {
819
- this . showContextViewHelper ( params , menuActions ) ;
820
- } else {
821
- this . _contextMenuService . showContextMenu ( {
822
- domForShadowRoot : useShadowDOM ? this . _editor . getDomNode ( ) ! : undefined ,
823
- getAnchor : ( ) => anchor ,
824
- getActions : ( ) => menuActions ,
825
- onHide : ( didCancel ) => {
826
- const openedFromString = ( options . fromLightbulb ) ? CodeActionTriggerSource . Lightbulb : trigger . triggerAction ;
827
- this . codeActionTelemetry ( openedFromString , didCancel , codeActions ) ;
828
- this . _visible = false ;
829
- this . _editor . focus ( ) ;
830
- } ,
831
- autoSelectFirstItem : true ,
832
- getKeyBinding : action => action instanceof CodeActionAction ? resolver ( action . action ) : undefined ,
833
- } ) ;
834
- }
796
+ this . showContextViewHelper ( params , menuActions ) ;
835
797
}
836
798
837
799
private getMenuActions (
0 commit comments