@@ -14,12 +14,13 @@ import { isNative } from 'vs/base/common/platform';
14
14
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService' ;
15
15
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent' ;
16
16
import { Event as BaseEvent } from 'vs/base/common/event' ;
17
+ import { Lazy } from 'vs/base/common/lazy' ;
17
18
18
19
export class TextInputActionsProvider extends Disposable implements IWorkbenchContribution {
19
20
20
21
static readonly ID = 'workbench.contrib.textInputActionsProvider' ;
21
22
22
- private textInputActions : IAction [ ] = [ ] ;
23
+ private readonly textInputActions = new Lazy < IAction [ ] > ( ( ) => this . createActions ( ) ) ;
23
24
24
25
constructor (
25
26
@IWorkbenchLayoutService private readonly layoutService : IWorkbenchLayoutService ,
@@ -28,13 +29,11 @@ export class TextInputActionsProvider extends Disposable implements IWorkbenchCo
28
29
) {
29
30
super ( ) ;
30
31
31
- this . createActions ( ) ;
32
-
33
32
this . registerListeners ( ) ;
34
33
}
35
34
36
- private createActions ( ) : void {
37
- this . textInputActions . push (
35
+ private createActions ( ) : IAction [ ] {
36
+ return [
38
37
39
38
// Undo/Redo
40
39
new Action ( 'undo' , localize ( 'undo' , "Undo" ) , undefined , true , async ( ) => getActiveDocument ( ) . execCommand ( 'undo' ) ) ,
@@ -72,7 +71,7 @@ export class TextInputActionsProvider extends Disposable implements IWorkbenchCo
72
71
73
72
// Select All
74
73
new Action ( 'editor.action.selectAll' , localize ( 'selectAll' , "Select All" ) , undefined , true , async ( ) => getActiveDocument ( ) . execCommand ( 'selectAll' ) )
75
- ) ;
74
+ ] ;
76
75
}
77
76
78
77
private registerListeners ( ) : void {
@@ -99,10 +98,14 @@ export class TextInputActionsProvider extends Disposable implements IWorkbenchCo
99
98
100
99
this . contextMenuService . showContextMenu ( {
101
100
getAnchor : ( ) => event ,
102
- getActions : ( ) => this . textInputActions ,
101
+ getActions : ( ) => this . textInputActions . value ,
103
102
getActionsContext : ( ) => target ,
104
103
} ) ;
105
104
}
106
105
}
107
106
108
- registerWorkbenchContribution2 ( TextInputActionsProvider . ID , TextInputActionsProvider , WorkbenchContributionInstantiation . BlockRestore ) ;
107
+ registerWorkbenchContribution2 (
108
+ TextInputActionsProvider . ID ,
109
+ TextInputActionsProvider ,
110
+ WorkbenchContributionInstantiation . BlockRestore // Block to allow right-click into input fields before restore finished
111
+ ) ;
0 commit comments