@theia/monaco 1.45.0 → 1.46.0-next.72

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/README.md +100 -100
  2. package/data/monaco-nls.json +1379 -1379
  3. package/data/monaco-themes/vscode/dark_plus.json +201 -201
  4. package/data/monaco-themes/vscode/dark_theia.json +5 -5
  5. package/data/monaco-themes/vscode/dark_vs.json +393 -393
  6. package/data/monaco-themes/vscode/hc_black.json +457 -457
  7. package/data/monaco-themes/vscode/hc_light.json +590 -590
  8. package/data/monaco-themes/vscode/hc_theia.json +5 -5
  9. package/data/monaco-themes/vscode/hc_theia_light.json +5 -5
  10. package/data/monaco-themes/vscode/light_plus.json +202 -202
  11. package/data/monaco-themes/vscode/light_theia.json +10 -10
  12. package/data/monaco-themes/vscode/light_vs.json +421 -421
  13. package/lib/browser/index.d.ts +1 -1
  14. package/lib/browser/index.js +28 -28
  15. package/lib/browser/markdown-renderer/monaco-markdown-renderer.d.ts +20 -24
  16. package/lib/browser/markdown-renderer/monaco-markdown-renderer.d.ts.map +1 -1
  17. package/lib/browser/markdown-renderer/monaco-markdown-renderer.js +122 -137
  18. package/lib/browser/markdown-renderer/monaco-markdown-renderer.js.map +1 -1
  19. package/lib/browser/monaco-bulk-edit-service.d.ts +12 -14
  20. package/lib/browser/monaco-bulk-edit-service.d.ts.map +1 -1
  21. package/lib/browser/monaco-bulk-edit-service.js +66 -66
  22. package/lib/browser/monaco-bulk-edit-service.js.map +1 -1
  23. package/lib/browser/monaco-color-registry.d.ts +16 -16
  24. package/lib/browser/monaco-color-registry.js +82 -82
  25. package/lib/browser/monaco-command-registry.d.ts +19 -19
  26. package/lib/browser/monaco-command-registry.d.ts.map +1 -1
  27. package/lib/browser/monaco-command-registry.js +88 -85
  28. package/lib/browser/monaco-command-registry.js.map +1 -1
  29. package/lib/browser/monaco-command-service.d.ts +21 -26
  30. package/lib/browser/monaco-command-service.d.ts.map +1 -1
  31. package/lib/browser/monaco-command-service.js +93 -92
  32. package/lib/browser/monaco-command-service.js.map +1 -1
  33. package/lib/browser/monaco-command.d.ts +88 -94
  34. package/lib/browser/monaco-command.d.ts.map +1 -1
  35. package/lib/browser/monaco-command.js +294 -307
  36. package/lib/browser/monaco-command.js.map +1 -1
  37. package/lib/browser/monaco-context-key-service.d.ts +22 -22
  38. package/lib/browser/monaco-context-key-service.d.ts.map +1 -1
  39. package/lib/browser/monaco-context-key-service.js +146 -147
  40. package/lib/browser/monaco-context-key-service.js.map +1 -1
  41. package/lib/browser/monaco-context-menu.d.ts +17 -16
  42. package/lib/browser/monaco-context-menu.d.ts.map +1 -1
  43. package/lib/browser/monaco-context-menu.js +112 -102
  44. package/lib/browser/monaco-context-menu.js.map +1 -1
  45. package/lib/browser/monaco-diff-editor.d.ts +29 -29
  46. package/lib/browser/monaco-diff-editor.d.ts.map +1 -1
  47. package/lib/browser/monaco-diff-editor.js +74 -74
  48. package/lib/browser/monaco-diff-editor.js.map +1 -1
  49. package/lib/browser/monaco-diff-navigator-factory.d.ts +6 -7
  50. package/lib/browser/monaco-diff-navigator-factory.d.ts.map +1 -1
  51. package/lib/browser/monaco-diff-navigator-factory.js +45 -66
  52. package/lib/browser/monaco-diff-navigator-factory.js.map +1 -1
  53. package/lib/browser/monaco-editor-model.d.ts +158 -156
  54. package/lib/browser/monaco-editor-model.d.ts.map +1 -1
  55. package/lib/browser/monaco-editor-model.js +562 -559
  56. package/lib/browser/monaco-editor-model.js.map +1 -1
  57. package/lib/browser/monaco-editor-provider.d.ts +70 -89
  58. package/lib/browser/monaco-editor-provider.d.ts.map +1 -1
  59. package/lib/browser/monaco-editor-provider.js +386 -440
  60. package/lib/browser/monaco-editor-provider.js.map +1 -1
  61. package/lib/browser/monaco-editor-service.d.ts +32 -27
  62. package/lib/browser/monaco-editor-service.d.ts.map +1 -1
  63. package/lib/browser/monaco-editor-service.js +158 -155
  64. package/lib/browser/monaco-editor-service.js.map +1 -1
  65. package/lib/browser/monaco-editor-zone-widget.d.ts +43 -43
  66. package/lib/browser/monaco-editor-zone-widget.js +194 -194
  67. package/lib/browser/monaco-editor.d.ts +154 -151
  68. package/lib/browser/monaco-editor.d.ts.map +1 -1
  69. package/lib/browser/monaco-editor.js +542 -524
  70. package/lib/browser/monaco-editor.js.map +1 -1
  71. package/lib/browser/monaco-formatting-conflicts.d.ts +13 -13
  72. package/lib/browser/monaco-formatting-conflicts.js +111 -111
  73. package/lib/browser/monaco-formatting-conflicts.js.map +1 -1
  74. package/lib/browser/monaco-frontend-application-contribution.d.ts +22 -28
  75. package/lib/browser/monaco-frontend-application-contribution.d.ts.map +1 -1
  76. package/lib/browser/monaco-frontend-application-contribution.js +178 -215
  77. package/lib/browser/monaco-frontend-application-contribution.js.map +1 -1
  78. package/lib/browser/monaco-frontend-module.d.ts +7 -7
  79. package/lib/browser/monaco-frontend-module.d.ts.map +1 -1
  80. package/lib/browser/monaco-frontend-module.js +280 -271
  81. package/lib/browser/monaco-frontend-module.js.map +1 -1
  82. package/lib/browser/monaco-gotoline-quick-access.d.ts +11 -11
  83. package/lib/browser/monaco-gotoline-quick-access.js +64 -64
  84. package/lib/browser/monaco-gotosymbol-quick-access.d.ts +16 -16
  85. package/lib/browser/monaco-gotosymbol-quick-access.js +70 -70
  86. package/lib/browser/monaco-icon-registry.d.ts +10 -11
  87. package/lib/browser/monaco-icon-registry.d.ts.map +1 -1
  88. package/lib/browser/monaco-icon-registry.js +52 -50
  89. package/lib/browser/monaco-icon-registry.js.map +1 -1
  90. package/lib/browser/monaco-indexed-db.d.ts +28 -28
  91. package/lib/browser/monaco-indexed-db.js +131 -131
  92. package/lib/browser/monaco-init.d.ts +5 -0
  93. package/lib/browser/monaco-init.d.ts.map +1 -0
  94. package/lib/browser/monaco-init.js +125 -0
  95. package/lib/browser/monaco-init.js.map +1 -0
  96. package/lib/browser/monaco-keybinding.d.ts +16 -16
  97. package/lib/browser/monaco-keybinding.js +134 -134
  98. package/lib/browser/monaco-keybinding.js.map +1 -1
  99. package/lib/browser/monaco-keycode-map.d.ts +2 -2
  100. package/lib/browser/monaco-keycode-map.js +163 -163
  101. package/lib/browser/monaco-keycode-map.js.map +1 -1
  102. package/lib/browser/monaco-languages.d.ts +35 -35
  103. package/lib/browser/monaco-languages.js +180 -180
  104. package/lib/browser/monaco-marker-collection.d.ts +18 -18
  105. package/lib/browser/monaco-marker-collection.js +70 -70
  106. package/lib/browser/monaco-menu.d.ts +20 -20
  107. package/lib/browser/monaco-menu.js +145 -145
  108. package/lib/browser/monaco-mime-service.d.ts +10 -10
  109. package/lib/browser/monaco-mime-service.js +78 -78
  110. package/lib/browser/monaco-outline-contribution.d.ts +78 -78
  111. package/lib/browser/monaco-outline-contribution.js +384 -384
  112. package/lib/browser/monaco-outline-decorator.d.ts +12 -12
  113. package/lib/browser/monaco-outline-decorator.js +67 -67
  114. package/lib/browser/monaco-quick-access-registry.d.ts +11 -11
  115. package/lib/browser/monaco-quick-access-registry.js +99 -99
  116. package/lib/browser/monaco-quick-input-service.d.ts +99 -101
  117. package/lib/browser/monaco-quick-input-service.d.ts.map +1 -1
  118. package/lib/browser/monaco-quick-input-service.js +529 -568
  119. package/lib/browser/monaco-quick-input-service.js.map +1 -1
  120. package/lib/browser/monaco-resolved-keybinding.d.ts +23 -23
  121. package/lib/browser/monaco-resolved-keybinding.d.ts.map +1 -1
  122. package/lib/browser/monaco-resolved-keybinding.js +131 -131
  123. package/lib/browser/monaco-resolved-keybinding.js.map +1 -1
  124. package/lib/browser/monaco-snippet-suggest-provider.d.ts +66 -66
  125. package/lib/browser/monaco-snippet-suggest-provider.js +273 -273
  126. package/lib/browser/monaco-status-bar-contribution.d.ts +17 -17
  127. package/lib/browser/monaco-status-bar-contribution.js +121 -121
  128. package/lib/browser/monaco-text-model-service.d.ts +51 -51
  129. package/lib/browser/monaco-text-model-service.js +189 -189
  130. package/lib/browser/monaco-text-model-service.js.map +1 -1
  131. package/lib/browser/monaco-theming-service.d.ts +67 -67
  132. package/lib/browser/monaco-theming-service.js +171 -171
  133. package/lib/browser/monaco-to-protocol-converter.d.ts +26 -26
  134. package/lib/browser/monaco-to-protocol-converter.js +61 -61
  135. package/lib/browser/monaco-workspace.d.ts +83 -85
  136. package/lib/browser/monaco-workspace.d.ts.map +1 -1
  137. package/lib/browser/monaco-workspace.js +384 -384
  138. package/lib/browser/monaco-workspace.js.map +1 -1
  139. package/lib/browser/protocol-to-monaco-converter.d.ts +31 -31
  140. package/lib/browser/protocol-to-monaco-converter.js +133 -133
  141. package/lib/browser/simple-monaco-editor.d.ts +45 -44
  142. package/lib/browser/simple-monaco-editor.d.ts.map +1 -1
  143. package/lib/browser/simple-monaco-editor.js +184 -176
  144. package/lib/browser/simple-monaco-editor.js.map +1 -1
  145. package/lib/browser/textmate/index.d.ts +4 -4
  146. package/lib/browser/textmate/index.js +31 -31
  147. package/lib/browser/textmate/monaco-textmate-frontend-bindings.d.ts +11 -11
  148. package/lib/browser/textmate/monaco-textmate-frontend-bindings.js +91 -91
  149. package/lib/browser/textmate/monaco-textmate-service.d.ts +30 -30
  150. package/lib/browser/textmate/monaco-textmate-service.js +185 -185
  151. package/lib/browser/textmate/monaco-textmate-service.js.map +1 -1
  152. package/lib/browser/textmate/monaco-theme-registry.d.ts +27 -27
  153. package/lib/browser/textmate/monaco-theme-registry.js +173 -173
  154. package/lib/browser/textmate/monaco-theme-types.d.ts +20 -20
  155. package/lib/browser/textmate/monaco-theme-types.js +21 -21
  156. package/lib/browser/textmate/textmate-contribution.d.ts +9 -9
  157. package/lib/browser/textmate/textmate-contribution.js +27 -27
  158. package/lib/browser/textmate/textmate-registry.d.ts +31 -31
  159. package/lib/browser/textmate/textmate-registry.js +109 -109
  160. package/lib/browser/textmate/textmate-snippet-completion-provider.d.ts +26 -26
  161. package/lib/browser/textmate/textmate-snippet-completion-provider.js +53 -53
  162. package/lib/browser/textmate/textmate-tokenizer.d.ts +22 -22
  163. package/lib/browser/textmate/textmate-tokenizer.js +65 -65
  164. package/lib/browser/workspace-symbol-command.d.ts +55 -55
  165. package/lib/browser/workspace-symbol-command.js +215 -215
  166. package/lib/package.spec.js +25 -25
  167. package/package.json +10 -10
  168. package/src/browser/index.ts +17 -17
  169. package/src/browser/markdown-renderer/monaco-markdown-renderer.ts +109 -117
  170. package/src/browser/monaco-bulk-edit-service.ts +64 -64
  171. package/src/browser/monaco-color-registry.ts +73 -73
  172. package/src/browser/monaco-command-registry.ts +85 -82
  173. package/src/browser/monaco-command-service.ts +90 -99
  174. package/src/browser/monaco-command.ts +303 -313
  175. package/src/browser/monaco-context-key-service.ts +144 -143
  176. package/src/browser/monaco-context-menu.ts +100 -90
  177. package/src/browser/monaco-diff-editor.ts +100 -101
  178. package/src/browser/monaco-diff-navigator-factory.ts +39 -61
  179. package/src/browser/monaco-editor-model.ts +684 -681
  180. package/src/browser/monaco-editor-provider.ts +409 -452
  181. package/src/browser/monaco-editor-service.ts +149 -144
  182. package/src/browser/monaco-editor-zone-widget.ts +250 -250
  183. package/src/browser/monaco-editor.ts +663 -644
  184. package/src/browser/monaco-formatting-conflicts.ts +116 -116
  185. package/src/browser/monaco-frontend-application-contribution.ts +165 -200
  186. package/src/browser/monaco-frontend-module.ts +328 -320
  187. package/src/browser/monaco-gotoline-quick-access.ts +47 -47
  188. package/src/browser/monaco-gotosymbol-quick-access.ts +53 -53
  189. package/src/browser/monaco-icon-registry.ts +49 -47
  190. package/src/browser/monaco-indexed-db.ts +130 -130
  191. package/src/browser/monaco-init.ts +114 -0
  192. package/src/browser/monaco-keybinding.ts +111 -111
  193. package/src/browser/monaco-keycode-map.ts +171 -171
  194. package/src/browser/monaco-languages.ts +177 -177
  195. package/src/browser/monaco-marker-collection.ts +83 -83
  196. package/src/browser/monaco-menu.ts +142 -142
  197. package/src/browser/monaco-mime-service.ts +71 -71
  198. package/src/browser/monaco-outline-contribution.ts +404 -404
  199. package/src/browser/monaco-outline-decorator.ts +66 -66
  200. package/src/browser/monaco-quick-access-registry.ts +112 -112
  201. package/src/browser/monaco-quick-input-service.ts +647 -676
  202. package/src/browser/monaco-resolved-keybinding.ts +162 -162
  203. package/src/browser/monaco-snippet-suggest-provider.ts +306 -306
  204. package/src/browser/monaco-status-bar-contribution.ts +110 -110
  205. package/src/browser/monaco-text-model-service.ts +199 -199
  206. package/src/browser/monaco-theming-service.ts +204 -204
  207. package/src/browser/monaco-to-protocol-converter.ts +71 -71
  208. package/src/browser/monaco-workspace.ts +412 -412
  209. package/src/browser/protocol-to-monaco-converter.ts +158 -158
  210. package/src/browser/simple-monaco-editor.ts +217 -210
  211. package/src/browser/style/index.css +263 -263
  212. package/src/browser/textmate/index.ts +20 -20
  213. package/src/browser/textmate/monaco-textmate-frontend-bindings.ts +90 -90
  214. package/src/browser/textmate/monaco-textmate-service.ts +187 -187
  215. package/src/browser/textmate/monaco-theme-registry.ts +176 -176
  216. package/src/browser/textmate/monaco-theme-types.ts +37 -37
  217. package/src/browser/textmate/textmate-contribution.ts +29 -29
  218. package/src/browser/textmate/textmate-registry.ts +129 -129
  219. package/src/browser/textmate/textmate-snippet-completion-provider.ts +73 -73
  220. package/src/browser/textmate/textmate-tokenizer.ts +84 -84
  221. package/src/browser/workspace-symbol-command.ts +196 -196
  222. package/src/package.spec.ts +28 -28
@@ -1,676 +1,647 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2021 SAP SE or an SAP affiliate company and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import {
18
- ApplicationShell,
19
- InputBox, InputOptions, KeybindingRegistry, NormalizedQuickInputButton, PickOptions,
20
- QuickInputButton, QuickInputHideReason, QuickInputService, QuickPick, QuickPickItem,
21
- QuickPickItemButtonEvent, QuickPickItemHighlights, QuickPickOptions, QuickPickSeparator, codiconArray
22
- } from '@theia/core/lib/browser';
23
- import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
24
- import {
25
- IInputBox, IInputOptions, IKeyMods, IPickOptions, IQuickInput, IQuickInputButton,
26
- IQuickInputService, IQuickNavigateConfiguration, IQuickPick, IQuickPickItem, IQuickPickItemButtonEvent, IQuickPickSeparator, QuickPickInput
27
- } from '@theia/monaco-editor-core/esm/vs/platform/quickinput/common/quickInput';
28
- import { IQuickInputOptions, IQuickInputStyles, QuickInputController } from '@theia/monaco-editor-core/esm/vs/base/parts/quickinput/browser/quickInput';
29
- import { MonacoResolvedKeybinding } from './monaco-resolved-keybinding';
30
- import { IQuickAccessController } from '@theia/monaco-editor-core/esm/vs/platform/quickinput/common/quickAccess';
31
- import { QuickAccessController } from '@theia/monaco-editor-core/esm/vs/platform/quickinput/browser/quickAccess';
32
- import { ContextKeyService as VSCodeContextKeyService } from '@theia/monaco-editor-core/esm/vs/platform/contextkey/browser/contextKeyService';
33
- import { IContextKey } from '@theia/monaco-editor-core/esm/vs/platform/contextkey/common/contextkey';
34
- import { IListOptions, List } from '@theia/monaco-editor-core/esm/vs/base/browser/ui/list/listWidget';
35
- import * as monaco from '@theia/monaco-editor-core';
36
- import { ResolvedKeybinding } from '@theia/monaco-editor-core/esm/vs/base/common/keybindings';
37
- import { IInstantiationService } from '@theia/monaco-editor-core/esm/vs/platform/instantiation/common/instantiation';
38
- import { StandaloneServices } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
39
- import { IMatch } from '@theia/monaco-editor-core/esm/vs/base/common/filters';
40
- import { IListRenderer, IListVirtualDelegate } from '@theia/monaco-editor-core/esm/vs/base/browser/ui/list/list';
41
- import { Event } from '@theia/core';
42
- import { MonacoColorRegistry } from './monaco-color-registry';
43
- import { ThemeService } from '@theia/core/lib/browser/theming';
44
- import { IStandaloneThemeService } from '@theia/monaco-editor-core/esm/vs/editor/standalone/common/standaloneTheme';
45
- import { ThemeIcon } from '@theia/monaco-editor-core/esm/vs/platform/theme/common/themeService';
46
-
47
- // Copied from @vscode/src/vs/base/parts/quickInput/browser/quickInputList.ts
48
- export interface IListElement {
49
- readonly index: number;
50
- readonly item: IQuickPickItem;
51
- readonly saneLabel: string;
52
- readonly saneAriaLabel: string;
53
- readonly saneDescription?: string;
54
- readonly saneDetail?: string;
55
- readonly labelHighlights?: IMatch[];
56
- readonly descriptionHighlights?: IMatch[];
57
- readonly detailHighlights?: IMatch[];
58
- readonly checked: boolean;
59
- readonly separator?: IQuickPickSeparator;
60
- readonly fireButtonTriggered: (event: IQuickPickItemButtonEvent<IQuickPickItem>) => void;
61
- }
62
-
63
- @injectable()
64
- export class MonacoQuickInputImplementation implements IQuickInputService {
65
- declare readonly _serviceBrand: undefined;
66
-
67
- controller: QuickInputController;
68
- quickAccess: IQuickAccessController;
69
-
70
- @inject(ApplicationShell)
71
- protected readonly shell: ApplicationShell;
72
-
73
- @inject(MonacoColorRegistry)
74
- protected readonly colorRegistry: MonacoColorRegistry;
75
-
76
- @inject(ThemeService)
77
- protected readonly themeService: ThemeService;
78
-
79
- @inject(VSCodeContextKeyService)
80
- protected readonly contextKeyService: VSCodeContextKeyService;
81
-
82
- protected container: HTMLElement;
83
- private quickInputList: List<unknown>;
84
-
85
- protected inQuickOpen: IContextKey<boolean>;
86
-
87
- get backButton(): IQuickInputButton { return this.controller.backButton; }
88
- get onShow(): monaco.IEvent<void> { return this.controller.onShow; }
89
- get onHide(): monaco.IEvent<void> { return this.controller.onHide; }
90
-
91
- @postConstruct()
92
- protected init(): void {
93
- this.initContainer();
94
- this.initController();
95
- this.quickAccess = new QuickAccessController(this, StandaloneServices.get(IInstantiationService));
96
- this.inQuickOpen = this.contextKeyService.createKey<boolean>('inQuickOpen', false);
97
- this.controller.onShow(() => {
98
- this.container.style.top = this.shell.mainPanel.node.getBoundingClientRect().top + 'px';
99
- this.inQuickOpen.set(true);
100
- });
101
- this.controller.onHide(() => this.inQuickOpen.set(false));
102
-
103
- this.themeService.initialized.then(() => this.controller.applyStyles(this.getStyles()));
104
- // Hook into the theming service of Monaco to ensure that the updates are ready.
105
- StandaloneServices.get(IStandaloneThemeService).onDidColorThemeChange(() => this.controller.applyStyles(this.getStyles()));
106
- window.addEventListener('resize', () => this.updateLayout());
107
- }
108
-
109
- setContextKey(key: string | undefined): void {
110
- if (key) {
111
- this.contextKeyService.createKey<string>(key, undefined);
112
- }
113
- }
114
-
115
- createQuickPick<T extends IQuickPickItem>(): IQuickPick<T> {
116
- return this.controller.createQuickPick<T>();
117
- }
118
-
119
- createInputBox(): IInputBox {
120
- return this.controller.createInputBox();
121
- }
122
-
123
- open(filter: string): void {
124
- this.quickAccess.show(filter);
125
- setTimeout(() => {
126
- this.quickInputList.focusNth(0);
127
- }, 300);
128
- }
129
-
130
- input(options?: IInputOptions, token?: monaco.CancellationToken): Promise<string | undefined> {
131
- return this.controller.input(options, token);
132
- }
133
-
134
- pick<T extends IQuickPickItem, O extends IPickOptions<T>>(
135
- picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: O, token?: monaco.CancellationToken
136
- ): Promise<(O extends { canPickMany: true; } ? T[] : T) | undefined> {
137
- return this.controller.pick(picks, options, token);
138
- }
139
-
140
- hide(): void {
141
- this.controller.hide();
142
- }
143
-
144
- focus(): void {
145
- this.controller.focus();
146
- }
147
-
148
- toggle(): void {
149
- this.controller.toggle();
150
- }
151
-
152
- applyStyles(styles: IQuickInputStyles): void {
153
- this.controller.applyStyles(styles);
154
- }
155
-
156
- layout(dimension: monaco.editor.IDimension, titleBarOffset: number): void {
157
- this.controller.layout(dimension, titleBarOffset);
158
- }
159
-
160
- navigate(next: boolean, quickNavigate?: IQuickNavigateConfiguration): void {
161
- this.controller.navigate(next, quickNavigate);
162
- }
163
-
164
- dispose(): void {
165
- this.controller.dispose();
166
- }
167
-
168
- async cancel(): Promise<void> {
169
- this.controller.cancel();
170
- }
171
-
172
- async back(): Promise<void> {
173
- this.controller.back();
174
- }
175
-
176
- async accept(keyMods?: IKeyMods): Promise<void> {
177
- this.controller.accept(keyMods);
178
- }
179
-
180
- private initContainer(): void {
181
- const container = this.container = document.createElement('div');
182
- container.id = 'quick-input-container';
183
- document.body.appendChild(this.container);
184
- }
185
-
186
- private initController(): void {
187
- this.controller = new QuickInputController(this.getOptions());
188
- this.updateLayout();
189
- }
190
-
191
- private updateLayout(): void {
192
- // Initialize the layout using screen dimensions as monaco computes the actual sizing.
193
- // https://github.com/microsoft/vscode/blob/6261075646f055b99068d3688932416f2346dd3b/src/vs/base/parts/quickinput/browser/quickInput.ts#L1799
194
- this.controller.layout(this.getClientDimension(), 0);
195
- }
196
-
197
- private getClientDimension(): monaco.editor.IDimension {
198
- return { width: window.innerWidth, height: window.innerHeight };
199
- }
200
-
201
- private getOptions(): IQuickInputOptions {
202
- const options: IQuickInputOptions = {
203
- idPrefix: 'quickInput_',
204
- container: this.container,
205
- styles: { widget: {}, list: {}, inputBox: {}, countBadge: {}, button: {}, progressBar: {}, keybindingLabel: {}, },
206
- ignoreFocusOut: () => false,
207
- isScreenReaderOptimized: () => false, // TODO change to true once support is added.
208
- backKeybindingLabel: () => undefined,
209
- setContextKey: (id?: string) => this.setContextKey(id),
210
- returnFocus: () => this.container.focus(),
211
- createList: <T>(
212
- user: string, container: HTMLElement, delegate: IListVirtualDelegate<T>, renderers: IListRenderer<T, unknown>[], listOptions: IListOptions<T>
213
- ): List<T> => this.quickInputList = new List(user, container, delegate, renderers, listOptions),
214
- };
215
- return options;
216
- }
217
-
218
- // @monaco-uplift
219
- // Keep the styles up to date with https://github.com/microsoft/vscode/blob/7888ff3a6b104e9e2e3d0f7890ca92dd0828215f/src/vs/platform/quickinput/browser/quickInput.ts#L171.
220
- private getStyles(): IQuickInputStyles {
221
- return {
222
- widget: {
223
- quickInputBackground: this.colorRegistry.getColor('quickInput.background'),
224
- quickInputForeground: this.colorRegistry.getColor('quickInput.foreground'),
225
- quickInputTitleBackground: this.colorRegistry.getColor('quickInputTitle.background')
226
- },
227
- list: {
228
- listBackground: this.colorRegistry.getColor('quickInput.background'),
229
- listInactiveFocusForeground: this.colorRegistry.getColor('quickInputList.focusForeground'),
230
- listInactiveSelectionIconForeground: this.colorRegistry.getColor('quickInputList.focusIconForeground'),
231
- listInactiveFocusBackground: this.colorRegistry.getColor('quickInputList.focusBackground'),
232
- listFocusOutline: this.colorRegistry.getColor('activeContrastBorder'),
233
- listInactiveFocusOutline: this.colorRegistry.getColor('activeContrastBorder'),
234
- pickerGroupBorder: this.colorRegistry.getColor('pickerGroup.border'),
235
- pickerGroupForeground: this.colorRegistry.getColor('pickerGroup.foreground')
236
- },
237
- inputBox: {
238
- inputForeground: this.colorRegistry.getColor('inputForeground'),
239
- inputBackground: this.colorRegistry.getColor('inputBackground'),
240
- inputBorder: this.colorRegistry.getColor('inputBorder'),
241
- inputValidationInfoBackground: this.colorRegistry.getColor('inputValidation.infoBackground'),
242
- inputValidationInfoForeground: this.colorRegistry.getColor('inputValidation.infoForeground'),
243
- inputValidationInfoBorder: this.colorRegistry.getColor('inputValidation.infoBorder'),
244
- inputValidationWarningBackground: this.colorRegistry.getColor('inputValidation.warningBackground'),
245
- inputValidationWarningForeground: this.colorRegistry.getColor('inputValidation.warningForeground'),
246
- inputValidationWarningBorder: this.colorRegistry.getColor('inputValidation.warningBorder'),
247
- inputValidationErrorBackground: this.colorRegistry.getColor('inputValidation.errorBackground'),
248
- inputValidationErrorForeground: this.colorRegistry.getColor('inputValidation.errorForeground'),
249
- inputValidationErrorBorder: this.colorRegistry.getColor('inputValidation.errorBorder'),
250
- },
251
- countBadge: {
252
- badgeBackground: this.colorRegistry.getColor('badge.background'),
253
- badgeForeground: this.colorRegistry.getColor('badge.foreground'),
254
- badgeBorder: this.colorRegistry.getColor('contrastBorder')
255
- },
256
- button: {
257
- buttonForeground: this.colorRegistry.getColor('button.foreground'),
258
- buttonBackground: this.colorRegistry.getColor('button.background'),
259
- buttonHoverBackground: this.colorRegistry.getColor('button.hoverBackground'),
260
- buttonBorder: this.colorRegistry.getColor('contrastBorder')
261
- },
262
- progressBar: {
263
- progressBarBackground: this.colorRegistry.getColor('progressBar.background')
264
- },
265
- keybindingLabel: {
266
- keybindingLabelBackground: this.colorRegistry.getColor('keybindingLabe.background'),
267
- keybindingLabelForeground: this.colorRegistry.getColor('keybindingLabel.foreground'),
268
- keybindingLabelBorder: this.colorRegistry.getColor('keybindingLabel.border'),
269
- keybindingLabelBottomBorder: this.colorRegistry.getColor('keybindingLabel.bottomBorder'),
270
- keybindingLabelShadow: this.colorRegistry.getColor('widget.shadow')
271
- },
272
- };
273
- }
274
- }
275
-
276
- @injectable()
277
- export class MonacoQuickInputService implements QuickInputService {
278
- @inject(MonacoQuickInputImplementation)
279
- private monacoService: MonacoQuickInputImplementation;
280
-
281
- @inject(KeybindingRegistry)
282
- protected readonly keybindingRegistry: KeybindingRegistry;
283
-
284
- get backButton(): QuickInputButton {
285
- return this.monacoService.backButton;
286
- }
287
-
288
- get onShow(): Event<void> { return this.monacoService.onShow; }
289
- get onHide(): Event<void> { return this.monacoService.onHide; }
290
-
291
- open(filter: string): void {
292
- this.monacoService.open(filter);
293
- }
294
-
295
- createInputBox(): InputBox {
296
- return this.monacoService.createInputBox();
297
- }
298
-
299
- input(options?: InputOptions, token?: monaco.CancellationToken): Promise<string | undefined> {
300
- let inputOptions: IInputOptions | undefined;
301
- if (options) {
302
- const { validateInput, ...props } = options;
303
- inputOptions = { ...props };
304
- if (validateInput) {
305
- inputOptions.validateInput = async input => validateInput(input);
306
- }
307
- }
308
- return this.monacoService.input(inputOptions, token);
309
- }
310
-
311
- async pick<T extends QuickPickItem, O extends PickOptions<T> = PickOptions<T>>(
312
- picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: O, token?: monaco.CancellationToken
313
- ): Promise<(O extends { canPickMany: true; } ? T[] : T) | undefined> {
314
- type M = T & { buttons?: NormalizedQuickInputButton[] };
315
- type R = (O extends { canPickMany: true; } ? T[] : T);
316
-
317
- const monacoPicks: Promise<QuickPickInput<IQuickPickItem>[]> = new Promise(async resolve => {
318
- const updatedPicks = (await picks).map(pick => {
319
- if (pick.type !== 'separator') {
320
- const icon = pick.iconPath;
321
- // @monaco-uplift
322
- // Other kind of icons (URI and URI dark/light) shall be supported once monaco editor has been upgraded to at least 1.81.
323
- // see https://github.com/eclipse-theia/theia/pull/12945#issue-1913645228
324
- if (ThemeIcon.isThemeIcon(icon)) {
325
- const codicon = codiconArray(icon.id);
326
- if (pick.iconClasses) {
327
- pick.iconClasses.push(...codicon);
328
- } else {
329
- pick.iconClasses = codicon;
330
- }
331
- }
332
- pick.buttons &&= pick.buttons.map(QuickInputButton.normalize);
333
- }
334
- return pick as M;
335
- });
336
- resolve(updatedPicks);
337
- });
338
- const monacoOptions = options as IPickOptions<M>;
339
- const picked = await this.monacoService.pick(monacoPicks, monacoOptions, token);
340
- if (!picked) { return picked; }
341
- if (options?.canPickMany) {
342
- return (Array.isArray(picked) ? picked : [picked]) as R;
343
- }
344
- return Array.isArray(picked) ? picked[0] : picked;
345
- }
346
-
347
- showQuickPick<T extends QuickPickItem>(items: Array<T | QuickPickSeparator>, options?: QuickPickOptions<T>): Promise<T | undefined> {
348
- return new Promise<T | undefined>((resolve, reject) => {
349
- const wrapped = this.createQuickPick<T>();
350
- wrapped.items = items;
351
-
352
- if (options) {
353
- wrapped.canSelectMany = !!options.canSelectMany;
354
- wrapped.contextKey = options.contextKey;
355
- wrapped.description = options.description;
356
- wrapped.enabled = options.enabled ?? true;
357
- wrapped.ignoreFocusOut = !!options.ignoreFocusOut;
358
- wrapped.matchOnDescription = options.matchOnDescription ?? true;
359
- wrapped.matchOnDetail = options.matchOnDetail ?? true;
360
- wrapped.keepScrollPosition = options.keepScrollPosition ?? false;
361
- wrapped.placeholder = options.placeholder;
362
- wrapped.step = options.step;
363
- wrapped.title = options.title;
364
- wrapped.totalSteps = options.totalSteps;
365
-
366
- if (options.activeItem) {
367
- wrapped.activeItems = [options.activeItem];
368
- }
369
-
370
- wrapped.onDidAccept(() => {
371
- if (options?.onDidAccept) {
372
- options.onDidAccept();
373
- }
374
- wrapped.hide();
375
- resolve(wrapped.selectedItems[0]);
376
- });
377
-
378
- wrapped.onDidHide(() => {
379
- if (options.onDidHide) {
380
- options.onDidHide();
381
- };
382
- wrapped.dispose();
383
- setTimeout(() => resolve(undefined));
384
- });
385
- wrapped.onDidChangeValue((filter: string) => {
386
- if (options.onDidChangeValue) {
387
- options.onDidChangeValue(wrapped, filter);
388
- }
389
- });
390
- wrapped.onDidChangeActive((activeItems: Array<T>) => {
391
- if (options.onDidChangeActive) {
392
- options.onDidChangeActive(wrapped, activeItems);
393
- }
394
- });
395
- wrapped.onDidTriggerButton((button: IQuickInputButton) => {
396
- if (options.onDidTriggerButton) {
397
- options.onDidTriggerButton(button);
398
- }
399
- });
400
- wrapped.onDidTriggerItemButton((event: QuickPickItemButtonEvent<T>) => {
401
- if (options.onDidTriggerItemButton) {
402
- // https://github.com/theia-ide/vscode/blob/standalone/0.23.x/src/vs/base/parts/quickinput/browser/quickInput.ts#L1387
403
- options.onDidTriggerItemButton(
404
- {
405
- ...event,
406
- removeItem: () => {
407
- wrapped.items = wrapped.items.filter(item => item !== event.item);
408
- wrapped.activeItems = wrapped.activeItems.filter(item => item !== event.item);
409
- }
410
- });
411
- }
412
- });
413
- wrapped.onDidChangeSelection((selectedItems: Array<T>) => {
414
- if (options.onDidChangeSelection) {
415
- options.onDidChangeSelection(wrapped, selectedItems);
416
- }
417
- });
418
- }
419
- wrapped.show();
420
- }).then(item => {
421
- if (item?.execute) {
422
- item.execute();
423
- }
424
- return item;
425
- });
426
- }
427
-
428
- createQuickPick<T extends QuickPickItem>(): QuickPick<T> {
429
- const quickPick = this.monacoService.createQuickPick<MonacoQuickPickItem<T>>();
430
- return this.wrapQuickPick(quickPick);
431
- }
432
-
433
- wrapQuickPick<T extends QuickPickItem>(wrapped: IQuickPick<MonacoQuickPickItem<T>>): QuickPick<T> {
434
- return new MonacoQuickPick(wrapped, this.keybindingRegistry);
435
- }
436
-
437
- protected convertItems<T extends QuickPickItem>(item: T): MonacoQuickPickItem<T> {
438
- return new MonacoQuickPickItem(item, this.keybindingRegistry);
439
- }
440
-
441
- hide(): void {
442
- return this.monacoService.hide();
443
- }
444
- }
445
-
446
- class MonacoQuickInput {
447
- constructor(protected readonly wrapped: IQuickInput) {
448
- }
449
-
450
- get onDidHide(): Event<{ reason: QuickInputHideReason }> { return this.wrapped.onDidHide; }
451
- get onDispose(): Event<void> { return this.wrapped.onDispose; }
452
-
453
- get title(): string | undefined {
454
- return this.wrapped.title;
455
- }
456
-
457
- set title(v: string | undefined) {
458
- this.wrapped.title = v;
459
- }
460
-
461
- get description(): string | undefined {
462
- return this.wrapped.description;
463
- }
464
-
465
- set description(v: string | undefined) {
466
- this.wrapped.description = v;
467
- }
468
- get step(): number | undefined {
469
- return this.wrapped.step;
470
- }
471
-
472
- set step(v: number | undefined) {
473
- this.wrapped.step = v;
474
- }
475
-
476
- get enabled(): boolean {
477
- return this.wrapped.enabled;
478
- }
479
-
480
- set enabled(v: boolean) {
481
- this.wrapped.enabled = v;
482
- }
483
- get totalSteps(): number | undefined {
484
- return this.wrapped.totalSteps;
485
- }
486
-
487
- set totalSteps(v: number | undefined) {
488
- this.wrapped.totalSteps = v;
489
- }
490
- get contextKey(): string | undefined {
491
- return this.wrapped.contextKey;
492
- }
493
-
494
- set contextKey(v: string | undefined) {
495
- this.wrapped.contextKey = v;
496
- }
497
-
498
- get busy(): boolean {
499
- return this.wrapped.busy;
500
- }
501
-
502
- set busy(v: boolean) {
503
- this.wrapped.busy = v;
504
- }
505
-
506
- get ignoreFocusOut(): boolean {
507
- return this.wrapped.ignoreFocusOut;
508
- }
509
-
510
- set ignoreFocusOut(v: boolean) {
511
- this.wrapped.ignoreFocusOut = v;
512
- }
513
-
514
- show(): void {
515
- this.wrapped.show();
516
- }
517
- hide(): void {
518
- this.wrapped.hide();
519
- }
520
- dispose(): void {
521
- this.wrapped.dispose();
522
- }
523
-
524
- }
525
-
526
- class MonacoQuickPick<T extends QuickPickItem> extends MonacoQuickInput implements QuickPick<T> {
527
- constructor(protected override readonly wrapped: IQuickPick<MonacoQuickPickItem<T>>, protected readonly keybindingRegistry: KeybindingRegistry) {
528
- super(wrapped);
529
- }
530
-
531
- get value(): string {
532
- return this.wrapped.value;
533
- };
534
-
535
- set value(v: string) {
536
- this.wrapped.value = v;
537
- }
538
-
539
- get placeholder(): string | undefined {
540
- return this.wrapped.placeholder;
541
- }
542
-
543
- set placeholder(v: string | undefined) {
544
- this.wrapped.placeholder = v;
545
- }
546
-
547
- get canSelectMany(): boolean {
548
- return this.wrapped.canSelectMany;
549
- }
550
-
551
- set canSelectMany(v: boolean) {
552
- this.wrapped.canSelectMany = v;
553
- }
554
-
555
- get matchOnDescription(): boolean {
556
- return this.wrapped.matchOnDescription;
557
- }
558
-
559
- set matchOnDescription(v: boolean) {
560
- this.wrapped.matchOnDescription = v;
561
- }
562
-
563
- get matchOnDetail(): boolean {
564
- return this.wrapped.matchOnDetail;
565
- }
566
-
567
- set matchOnDetail(v: boolean) {
568
- this.wrapped.matchOnDetail = v;
569
- }
570
-
571
- get keepScrollPosition(): boolean {
572
- return this.wrapped.keepScrollPosition;
573
- }
574
-
575
- set keepScrollPosition(v: boolean) {
576
- this.wrapped.keepScrollPosition = v;
577
- }
578
-
579
- get items(): readonly (T | QuickPickSeparator)[] {
580
- return this.wrapped.items.map(item => QuickPickSeparator.is(item) ? item : item.item);
581
- }
582
-
583
- set items(itemList: readonly (T | QuickPickSeparator)[]) {
584
- // We need to store and apply the currently selected active items.
585
- // Since monaco compares these items by reference equality, creating new wrapped items will unmark any active items.
586
- // Assigning the `activeItems` again will restore all active items even after the items array has changed.
587
- // See also the `findMonacoItemReferences` method.
588
- const active = this.activeItems;
589
- this.wrapped.items = itemList.map(item => QuickPickSeparator.is(item) ? item : new MonacoQuickPickItem<T>(item, this.keybindingRegistry));
590
- if (active.length !== 0) {
591
- this.activeItems = active; // If this is done with an empty activeItems array, then it will undo first item focus on quick menus.
592
- }
593
- }
594
-
595
- set activeItems(itemList: readonly T[]) {
596
- this.wrapped.activeItems = this.findMonacoItemReferences(this.wrapped.items, itemList);
597
- }
598
-
599
- get activeItems(): readonly (T)[] {
600
- return this.wrapped.activeItems.map(item => item.item);
601
- }
602
-
603
- set selectedItems(itemList: readonly T[]) {
604
- this.wrapped.selectedItems = this.findMonacoItemReferences(this.wrapped.items, itemList);
605
- }
606
-
607
- get selectedItems(): readonly (T)[] {
608
- return this.wrapped.selectedItems.map(item => item.item);
609
- }
610
-
611
- readonly onDidAccept: Event<{ inBackground: boolean }> = this.wrapped.onDidAccept;
612
- readonly onDidChangeValue: Event<string> = this.wrapped.onDidChangeValue;
613
- readonly onDidTriggerButton: Event<QuickInputButton> = this.wrapped.onDidTriggerButton;
614
- readonly onDidTriggerItemButton: Event<QuickPickItemButtonEvent<T>> =
615
- Event.map(this.wrapped.onDidTriggerItemButton, (evt: IQuickPickItemButtonEvent<MonacoQuickPickItem<T>>) => ({
616
- item: evt.item.item,
617
- button: evt.button
618
- }));
619
- readonly onDidChangeActive: Event<T[]> = Event.map(
620
- this.wrapped.onDidChangeActive,
621
- (items: MonacoQuickPickItem<T>[]) => items.map(item => item.item));
622
- readonly onDidChangeSelection: Event<T[]> = Event.map(
623
- this.wrapped.onDidChangeSelection, (items: MonacoQuickPickItem<T>[]) => items.map(item => item.item));
624
-
625
- /**
626
- * Monaco doesn't check for deep equality when setting the `activeItems` or `selectedItems`.
627
- * Instead we have to find the references of the monaco wrappers that contain the selected/active items
628
- */
629
- protected findMonacoItemReferences(source: readonly (MonacoQuickPickItem<T> | IQuickPickSeparator)[], items: readonly QuickPickItem[]): MonacoQuickPickItem<T>[] {
630
- const monacoReferences: MonacoQuickPickItem<T>[] = [];
631
- for (const item of items) {
632
- for (const wrappedItem of source) {
633
- if (!QuickPickSeparator.is(wrappedItem) && wrappedItem.item === item) {
634
- monacoReferences.push(wrappedItem);
635
- }
636
- }
637
- }
638
- return monacoReferences;
639
- }
640
- }
641
-
642
- export class MonacoQuickPickItem<T extends QuickPickItem> implements IQuickPickItem {
643
- readonly type?: 'item';
644
- readonly id?: string;
645
- readonly label: string;
646
- readonly meta?: string;
647
- readonly ariaLabel?: string;
648
- readonly description?: string;
649
- readonly detail?: string;
650
- readonly keybinding?: ResolvedKeybinding;
651
- readonly iconClasses?: string[];
652
- buttons?: IQuickInputButton[];
653
- readonly alwaysShow?: boolean;
654
- readonly highlights?: QuickPickItemHighlights;
655
-
656
- constructor(readonly item: T, kbRegistry: KeybindingRegistry) {
657
- this.type = item.type;
658
- this.id = item.id;
659
- this.label = item.label;
660
- this.meta = item.meta;
661
- this.ariaLabel = item.ariaLabel;
662
- this.description = item.description;
663
- this.detail = item.detail;
664
- this.keybinding = item.keySequence ? new MonacoResolvedKeybinding(item.keySequence, kbRegistry) : undefined;
665
- this.iconClasses = item.iconClasses;
666
- this.buttons = item.buttons?.map(QuickInputButton.normalize);
667
- this.alwaysShow = item.alwaysShow;
668
- this.highlights = item.highlights;
669
- }
670
-
671
- accept(): void {
672
- if (this.item.execute) {
673
- this.item.execute();
674
- }
675
- }
676
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2021 SAP SE or an SAP affiliate company and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import {
18
+ ApplicationShell,
19
+ InputBox, InputOptions, KeybindingRegistry, PickOptions,
20
+ QuickInputButton, QuickInputHideReason, QuickInputService, QuickPick, QuickPickItem,
21
+ QuickPickItemButtonEvent, QuickPickItemHighlights, QuickPickOptions, QuickPickSeparator
22
+ } from '@theia/core/lib/browser';
23
+ import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
24
+ import {
25
+ IInputBox, IInputOptions, IKeyMods, IPickOptions, IQuickInput, IQuickInputButton,
26
+ IQuickInputService, IQuickNavigateConfiguration, IQuickPick, IQuickPickItem, IQuickPickItemButtonEvent, IQuickPickSeparator, IQuickWidget, QuickPickInput
27
+ } from '@theia/monaco-editor-core/esm/vs/platform/quickinput/common/quickInput';
28
+ import { IQuickInputOptions, IQuickInputStyles } from '@theia/monaco-editor-core/esm/vs/platform/quickinput/browser/quickInput';
29
+ import { QuickInputController } from '@theia/monaco-editor-core/esm/vs/platform/quickinput/browser/quickInputController';
30
+ import { MonacoResolvedKeybinding } from './monaco-resolved-keybinding';
31
+ import { IQuickAccessController } from '@theia/monaco-editor-core/esm/vs/platform/quickinput/common/quickAccess';
32
+ import { QuickAccessController } from '@theia/monaco-editor-core/esm/vs/platform/quickinput/browser/quickAccess';
33
+ import { IContextKey, IContextKeyService } from '@theia/monaco-editor-core/esm/vs/platform/contextkey/common/contextkey';
34
+ import { IListOptions, List } from '@theia/monaco-editor-core/esm/vs/base/browser/ui/list/listWidget';
35
+ import * as monaco from '@theia/monaco-editor-core';
36
+ import { ResolvedKeybinding } from '@theia/monaco-editor-core/esm/vs/base/common/keybindings';
37
+ import { IInstantiationService } from '@theia/monaco-editor-core/esm/vs/platform/instantiation/common/instantiation';
38
+ import { StandaloneServices } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
39
+ import { IMatch } from '@theia/monaco-editor-core/esm/vs/base/common/filters';
40
+ import { IListRenderer, IListVirtualDelegate } from '@theia/monaco-editor-core/esm/vs/base/browser/ui/list/list';
41
+ import { CancellationToken, Event } from '@theia/core';
42
+ import { MonacoColorRegistry } from './monaco-color-registry';
43
+ import { ThemeService } from '@theia/core/lib/browser/theming';
44
+ import { IStandaloneThemeService } from '@theia/monaco-editor-core/esm/vs/editor/standalone/common/standaloneTheme';
45
+ import {
46
+ activeContrastBorder, asCssVariable, pickerGroupBorder, pickerGroupForeground, quickInputBackground, quickInputForeground, quickInputListFocusBackground,
47
+ quickInputListFocusForeground, quickInputListFocusIconForeground, quickInputTitleBackground, widgetBorder, widgetShadow
48
+ } from '@theia/monaco-editor-core/esm/vs/platform/theme/common/colorRegistry';
49
+
50
+ import {
51
+ defaultButtonStyles, defaultCountBadgeStyles, defaultInputBoxStyles, defaultKeybindingLabelStyles, defaultProgressBarStyles, defaultToggleStyles, getListStyles
52
+ } from '@theia/monaco-editor-core/esm/vs/platform/theme/browser/defaultStyles';
53
+
54
+ // Copied from @vscode/src/vs/base/parts/quickInput/browser/quickInputList.ts
55
+ export interface IListElement {
56
+ readonly index: number;
57
+ readonly item: IQuickPickItem;
58
+ readonly saneLabel: string;
59
+ readonly saneAriaLabel: string;
60
+ readonly saneDescription?: string;
61
+ readonly saneDetail?: string;
62
+ readonly labelHighlights?: IMatch[];
63
+ readonly descriptionHighlights?: IMatch[];
64
+ readonly detailHighlights?: IMatch[];
65
+ readonly checked: boolean;
66
+ readonly separator?: IQuickPickSeparator;
67
+ readonly fireButtonTriggered: (event: IQuickPickItemButtonEvent<IQuickPickItem>) => void;
68
+ }
69
+
70
+ @injectable()
71
+ export class MonacoQuickInputImplementation implements IQuickInputService {
72
+
73
+ declare readonly _serviceBrand: undefined;
74
+
75
+ controller: QuickInputController;
76
+ quickAccess: IQuickAccessController;
77
+
78
+ @inject(ApplicationShell)
79
+ protected readonly shell: ApplicationShell;
80
+
81
+ @inject(MonacoColorRegistry)
82
+ protected readonly colorRegistry: MonacoColorRegistry;
83
+
84
+ @inject(ThemeService)
85
+ protected readonly themeService: ThemeService;
86
+
87
+ protected container: HTMLElement;
88
+ private quickInputList: List<unknown>;
89
+
90
+ protected inQuickOpen: IContextKey<boolean>;
91
+
92
+ get backButton(): IQuickInputButton { return this.controller.backButton; }
93
+ get onShow(): monaco.IEvent<void> { return this.controller.onShow; }
94
+ get onHide(): monaco.IEvent<void> { return this.controller.onHide; }
95
+
96
+ @postConstruct()
97
+ protected init(): void {
98
+ this.initContainer();
99
+ this.initController();
100
+ this.quickAccess = new QuickAccessController(this, StandaloneServices.get(IInstantiationService));
101
+ this.inQuickOpen = StandaloneServices.get(IContextKeyService).createKey<boolean>('inQuickOpen', false);
102
+ this.controller.onShow(() => {
103
+ this.container.style.top = this.shell.mainPanel.node.getBoundingClientRect().top + 'px';
104
+ this.inQuickOpen.set(true);
105
+ });
106
+ this.controller.onHide(() => this.inQuickOpen.set(false));
107
+
108
+ this.themeService.initialized.then(() => this.controller.applyStyles(this.computeStyles()));
109
+ // Hook into the theming service of Monaco to ensure that the updates are ready.
110
+ StandaloneServices.get(IStandaloneThemeService).onDidColorThemeChange(() => this.controller.applyStyles(this.computeStyles()));
111
+ window.addEventListener('resize', () => this.updateLayout());
112
+ }
113
+
114
+ setContextKey(key: string | undefined): void {
115
+ if (key) {
116
+ StandaloneServices.get(IContextKeyService).createKey<string>(key, undefined);
117
+ }
118
+ }
119
+
120
+ createQuickWidget(): IQuickWidget {
121
+ return this.controller.createQuickWidget();
122
+ }
123
+
124
+ createQuickPick<T extends IQuickPickItem>(): IQuickPick<T> {
125
+ return this.controller.createQuickPick<T>();
126
+ }
127
+
128
+ createInputBox(): IInputBox {
129
+ return this.controller.createInputBox();
130
+ }
131
+
132
+ open(filter: string): void {
133
+ this.quickAccess.show(filter);
134
+ setTimeout(() => {
135
+ this.quickInputList.focusNth(0);
136
+ }, 300);
137
+ }
138
+
139
+ input(options?: IInputOptions, token?: monaco.CancellationToken): Promise<string | undefined> {
140
+ return this.controller.input(options, token);
141
+ }
142
+
143
+ pick<T extends IQuickPickItem, O extends IPickOptions<T>>(
144
+ picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: O, token?: monaco.CancellationToken
145
+ ): Promise<(O extends { canPickMany: true; } ? T[] : T) | undefined> {
146
+ return this.controller.pick(picks, options, token);
147
+ }
148
+
149
+ hide(): void {
150
+ this.controller.hide();
151
+ }
152
+
153
+ focus(): void {
154
+ this.controller.focus();
155
+ }
156
+
157
+ toggle(): void {
158
+ this.controller.toggle();
159
+ }
160
+
161
+ applyStyles(styles: IQuickInputStyles): void {
162
+ this.controller.applyStyles(styles);
163
+ }
164
+
165
+ layout(dimension: monaco.editor.IDimension, titleBarOffset: number): void {
166
+ this.controller.layout(dimension, titleBarOffset);
167
+ }
168
+
169
+ navigate(next: boolean, quickNavigate?: IQuickNavigateConfiguration): void {
170
+ this.controller.navigate(next, quickNavigate);
171
+ }
172
+
173
+ dispose(): void {
174
+ this.controller.dispose();
175
+ }
176
+
177
+ async cancel(): Promise<void> {
178
+ this.controller.cancel();
179
+ }
180
+
181
+ async back(): Promise<void> {
182
+ this.controller.back();
183
+ }
184
+
185
+ async accept(keyMods?: IKeyMods): Promise<void> {
186
+ this.controller.accept(keyMods);
187
+ }
188
+
189
+ private initContainer(): void {
190
+ const container = this.container = document.createElement('div');
191
+ container.id = 'quick-input-container';
192
+ document.body.appendChild(this.container);
193
+ }
194
+
195
+ private initController(): void {
196
+ this.controller = new QuickInputController(this.getOptions(), StandaloneServices.get(IStandaloneThemeService));
197
+ this.updateLayout();
198
+ }
199
+
200
+ private updateLayout(): void {
201
+ // Initialize the layout using screen dimensions as monaco computes the actual sizing.
202
+ // https://github.com/microsoft/vscode/blob/6261075646f055b99068d3688932416f2346dd3b/src/vs/base/parts/quickinput/browser/quickInput.ts#L1799
203
+ this.controller.layout(this.getClientDimension(), 0);
204
+ }
205
+
206
+ private getClientDimension(): monaco.editor.IDimension {
207
+ return { width: window.innerWidth, height: window.innerHeight };
208
+ }
209
+
210
+ private getOptions(): IQuickInputOptions {
211
+ const options: IQuickInputOptions = {
212
+ idPrefix: 'quickInput_',
213
+ container: this.container,
214
+ styles: this.computeStyles(),
215
+ ignoreFocusOut: () => false,
216
+ backKeybindingLabel: () => undefined,
217
+ setContextKey: (id?: string) => this.setContextKey(id),
218
+ returnFocus: () => this.container.focus(),
219
+ createList: <T>(
220
+ user: string, container: HTMLElement, delegate: IListVirtualDelegate<T>, renderers: IListRenderer<T, unknown>[], listOptions: IListOptions<T>
221
+ ): List<T> => this.quickInputList = new List(user, container, delegate, renderers, listOptions),
222
+ linkOpenerDelegate: () => {
223
+ // @monaco-uplift: not sure what to do here
224
+ }
225
+ };
226
+ return options;
227
+ }
228
+
229
+ // @monaco-uplift
230
+ // Keep the styles up to date with https://github.com/microsoft/vscode/blob/7888ff3a6b104e9e2e3d0f7890ca92dd0828215f/src/vs/platform/quickinput/browser/quickInput.ts#L171.
231
+ private computeStyles(): IQuickInputStyles {
232
+ return {
233
+ widget: {
234
+ quickInputBackground: asCssVariable(quickInputBackground),
235
+ quickInputForeground: asCssVariable(quickInputForeground),
236
+ quickInputTitleBackground: asCssVariable(quickInputTitleBackground),
237
+ widgetBorder: asCssVariable(widgetBorder),
238
+ widgetShadow: asCssVariable(widgetShadow),
239
+ },
240
+ inputBox: defaultInputBoxStyles,
241
+ toggle: defaultToggleStyles,
242
+ countBadge: defaultCountBadgeStyles,
243
+ button: defaultButtonStyles,
244
+ progressBar: defaultProgressBarStyles,
245
+ keybindingLabel: defaultKeybindingLabelStyles,
246
+ list: getListStyles({
247
+ listBackground: quickInputBackground,
248
+ listFocusBackground: quickInputListFocusBackground,
249
+ listFocusForeground: quickInputListFocusForeground,
250
+ // Look like focused when inactive.
251
+ listInactiveFocusForeground: quickInputListFocusForeground,
252
+ listInactiveSelectionIconForeground: quickInputListFocusIconForeground,
253
+ listInactiveFocusBackground: quickInputListFocusBackground,
254
+ listFocusOutline: activeContrastBorder,
255
+ listInactiveFocusOutline: activeContrastBorder,
256
+ }),
257
+ pickerGroup: {
258
+ pickerGroupBorder: asCssVariable(pickerGroupBorder),
259
+ pickerGroupForeground: asCssVariable(pickerGroupForeground),
260
+ }
261
+ };
262
+ }
263
+ }
264
+
265
+ @injectable()
266
+ export class MonacoQuickInputService implements QuickInputService {
267
+ @inject(MonacoQuickInputImplementation)
268
+ private monacoService: MonacoQuickInputImplementation;
269
+
270
+ @inject(KeybindingRegistry)
271
+ protected readonly keybindingRegistry: KeybindingRegistry;
272
+
273
+ get backButton(): QuickInputButton {
274
+ // need to cast because of vscode issue https://github.com/microsoft/vscode/issues/190584
275
+ return this.monacoService.backButton as QuickInputButton;
276
+ }
277
+
278
+ get onShow(): Event<void> { return this.monacoService.onShow; }
279
+ get onHide(): Event<void> { return this.monacoService.onHide; }
280
+
281
+ open(filter: string): void {
282
+ this.monacoService.open(filter);
283
+ }
284
+
285
+ createInputBox(): InputBox {
286
+ // need to cast because of vscode issue https://github.com/microsoft/vscode/issues/190584
287
+ return this.monacoService.createInputBox() as InputBox;
288
+ }
289
+
290
+ input(options?: InputOptions, token?: monaco.CancellationToken): Promise<string | undefined> {
291
+ let inputOptions: IInputOptions | undefined;
292
+ if (options) {
293
+ const { validateInput, ...props } = options;
294
+ inputOptions = { ...props };
295
+ if (validateInput) {
296
+ inputOptions.validateInput = async input => validateInput(input);
297
+ }
298
+ }
299
+ return this.monacoService.input(inputOptions, token);
300
+ }
301
+
302
+ async pick<T extends QuickPickItem, O extends PickOptions<T> = PickOptions<T>>(
303
+ picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: O, token?: CancellationToken
304
+ ): Promise<T[] | T | undefined> {
305
+ return this.monacoService.pick(picks, options, token);
306
+ }
307
+
308
+ showQuickPick<T extends QuickPickItem>(items: Array<T | QuickPickSeparator>, options?: QuickPickOptions<T>): Promise<T | undefined> {
309
+ return new Promise<T | undefined>((resolve, reject) => {
310
+ const wrapped = this.createQuickPick<T>();
311
+ wrapped.items = items;
312
+
313
+ if (options) {
314
+ wrapped.canSelectMany = !!options.canSelectMany;
315
+ wrapped.contextKey = options.contextKey;
316
+ wrapped.description = options.description;
317
+ wrapped.enabled = options.enabled ?? true;
318
+ wrapped.ignoreFocusOut = !!options.ignoreFocusOut;
319
+ wrapped.matchOnDescription = options.matchOnDescription ?? true;
320
+ wrapped.matchOnDetail = options.matchOnDetail ?? true;
321
+ wrapped.keepScrollPosition = options.keepScrollPosition ?? false;
322
+ wrapped.placeholder = options.placeholder;
323
+ wrapped.step = options.step;
324
+ wrapped.title = options.title;
325
+ wrapped.totalSteps = options.totalSteps;
326
+
327
+ if (options.activeItem) {
328
+ wrapped.activeItems = [options.activeItem];
329
+ }
330
+
331
+ wrapped.onDidAccept(() => {
332
+ if (options?.onDidAccept) {
333
+ options.onDidAccept();
334
+ }
335
+ wrapped.hide();
336
+ resolve(wrapped.selectedItems[0]);
337
+ });
338
+
339
+ wrapped.onDidHide(() => {
340
+ if (options.onDidHide) {
341
+ options.onDidHide();
342
+ };
343
+ wrapped.dispose();
344
+ setTimeout(() => resolve(undefined));
345
+ });
346
+ wrapped.onDidChangeValue((filter: string) => {
347
+ if (options.onDidChangeValue) {
348
+ options.onDidChangeValue(wrapped, filter);
349
+ }
350
+ });
351
+ wrapped.onDidChangeActive((activeItems: Array<T>) => {
352
+ if (options.onDidChangeActive) {
353
+ options.onDidChangeActive(wrapped, activeItems);
354
+ }
355
+ });
356
+ wrapped.onDidTriggerButton((button: IQuickInputButton) => {
357
+ if (options.onDidTriggerButton) {
358
+ // need to cast because of vscode issue https://github.com/microsoft/vscode/issues/190584
359
+ options.onDidTriggerButton(button as QuickInputButton);
360
+ }
361
+ });
362
+ wrapped.onDidTriggerItemButton((event: QuickPickItemButtonEvent<T>) => {
363
+ if (options.onDidTriggerItemButton) {
364
+ // https://github.com/theia-ide/vscode/blob/standalone/0.23.x/src/vs/base/parts/quickinput/browser/quickInput.ts#L1387
365
+ options.onDidTriggerItemButton(
366
+ {
367
+ ...event,
368
+ removeItem: () => {
369
+ wrapped.items = wrapped.items.filter(item => item !== event.item);
370
+ wrapped.activeItems = wrapped.activeItems.filter(item => item !== event.item);
371
+ }
372
+ });
373
+ }
374
+ });
375
+ wrapped.onDidChangeSelection((selectedItems: Array<T>) => {
376
+ if (options.onDidChangeSelection) {
377
+ options.onDidChangeSelection(wrapped, selectedItems);
378
+ }
379
+ });
380
+ }
381
+ wrapped.show();
382
+ }).then(item => {
383
+ if (item?.execute) {
384
+ item.execute();
385
+ }
386
+ return item;
387
+ });
388
+ }
389
+
390
+ createQuickPick<T extends QuickPickItem>(): QuickPick<T> {
391
+ const quickPick = this.monacoService.createQuickPick<MonacoQuickPickItem<T>>();
392
+ return this.wrapQuickPick(quickPick);
393
+ }
394
+
395
+ wrapQuickPick<T extends QuickPickItem>(wrapped: IQuickPick<MonacoQuickPickItem<T>>): QuickPick<T> {
396
+ return new MonacoQuickPick(wrapped, this.keybindingRegistry);
397
+ }
398
+
399
+ protected convertItems<T extends QuickPickItem>(item: T): MonacoQuickPickItem<T> {
400
+ return new MonacoQuickPickItem(item, this.keybindingRegistry);
401
+ }
402
+
403
+ hide(): void {
404
+ return this.monacoService.hide();
405
+ }
406
+ }
407
+
408
+ class MonacoQuickInput {
409
+ constructor(protected readonly wrapped: IQuickInput) {
410
+ }
411
+
412
+ get onDidHide(): Event<{ reason: QuickInputHideReason }> { return this.wrapped.onDidHide; }
413
+ get onDispose(): Event<void> { return this.wrapped.onDispose; }
414
+
415
+ get title(): string | undefined {
416
+ return this.wrapped.title;
417
+ }
418
+
419
+ set title(v: string | undefined) {
420
+ this.wrapped.title = v;
421
+ }
422
+
423
+ get description(): string | undefined {
424
+ return this.wrapped.description;
425
+ }
426
+
427
+ set description(v: string | undefined) {
428
+ this.wrapped.description = v;
429
+ }
430
+ get step(): number | undefined {
431
+ return this.wrapped.step;
432
+ }
433
+
434
+ set step(v: number | undefined) {
435
+ this.wrapped.step = v;
436
+ }
437
+
438
+ get enabled(): boolean {
439
+ return this.wrapped.enabled;
440
+ }
441
+
442
+ set enabled(v: boolean) {
443
+ this.wrapped.enabled = v;
444
+ }
445
+ get totalSteps(): number | undefined {
446
+ return this.wrapped.totalSteps;
447
+ }
448
+
449
+ set totalSteps(v: number | undefined) {
450
+ this.wrapped.totalSteps = v;
451
+ }
452
+ get contextKey(): string | undefined {
453
+ return this.wrapped.contextKey;
454
+ }
455
+
456
+ set contextKey(v: string | undefined) {
457
+ this.wrapped.contextKey = v;
458
+ }
459
+
460
+ get busy(): boolean {
461
+ return this.wrapped.busy;
462
+ }
463
+
464
+ set busy(v: boolean) {
465
+ this.wrapped.busy = v;
466
+ }
467
+
468
+ get ignoreFocusOut(): boolean {
469
+ return this.wrapped.ignoreFocusOut;
470
+ }
471
+
472
+ set ignoreFocusOut(v: boolean) {
473
+ this.wrapped.ignoreFocusOut = v;
474
+ }
475
+
476
+ show(): void {
477
+ this.wrapped.show();
478
+ }
479
+ hide(): void {
480
+ this.wrapped.hide();
481
+ }
482
+ dispose(): void {
483
+ this.wrapped.dispose();
484
+ }
485
+
486
+ }
487
+
488
+ class MonacoQuickPick<T extends QuickPickItem> extends MonacoQuickInput implements QuickPick<T> {
489
+ constructor(protected override readonly wrapped: IQuickPick<MonacoQuickPickItem<T>>, protected readonly keybindingRegistry: KeybindingRegistry) {
490
+ super(wrapped);
491
+ }
492
+
493
+ get value(): string {
494
+ return this.wrapped.value;
495
+ };
496
+
497
+ set value(v: string) {
498
+ this.wrapped.value = v;
499
+ }
500
+
501
+ get placeholder(): string | undefined {
502
+ return this.wrapped.placeholder;
503
+ }
504
+
505
+ set placeholder(v: string | undefined) {
506
+ this.wrapped.placeholder = v;
507
+ }
508
+
509
+ get canSelectMany(): boolean {
510
+ return this.wrapped.canSelectMany;
511
+ }
512
+
513
+ set canSelectMany(v: boolean) {
514
+ this.wrapped.canSelectMany = v;
515
+ }
516
+
517
+ get matchOnDescription(): boolean {
518
+ return this.wrapped.matchOnDescription;
519
+ }
520
+
521
+ set matchOnDescription(v: boolean) {
522
+ this.wrapped.matchOnDescription = v;
523
+ }
524
+
525
+ get matchOnDetail(): boolean {
526
+ return this.wrapped.matchOnDetail;
527
+ }
528
+
529
+ set matchOnDetail(v: boolean) {
530
+ this.wrapped.matchOnDetail = v;
531
+ }
532
+
533
+ get keepScrollPosition(): boolean {
534
+ return this.wrapped.keepScrollPosition;
535
+ }
536
+
537
+ set keepScrollPosition(v: boolean) {
538
+ this.wrapped.keepScrollPosition = v;
539
+ }
540
+
541
+ get items(): readonly (T | QuickPickSeparator)[] {
542
+ // need to cast because of vscode issue https://github.com/microsoft/vscode/issues/190584
543
+ return this.wrapped.items.map(item => {
544
+ if (item instanceof MonacoQuickPickItem) {
545
+ return item.item;
546
+ } else {
547
+ return item;
548
+ }
549
+ });
550
+ }
551
+
552
+ set items(itemList: readonly (T | QuickPickSeparator)[]) {
553
+ // We need to store and apply the currently selected active items.
554
+ // Since monaco compares these items by reference equality, creating new wrapped items will unmark any active items.
555
+ // Assigning the `activeItems` again will restore all active items even after the items array has changed.
556
+ // See also the `findMonacoItemReferences` method.
557
+ const active = this.activeItems;
558
+ this.wrapped.items = itemList.map(item => QuickPickSeparator.is(item) ? item : new MonacoQuickPickItem<T>(item, this.keybindingRegistry));
559
+ if (active.length !== 0) {
560
+ this.activeItems = active; // If this is done with an empty activeItems array, then it will undo first item focus on quick menus.
561
+ }
562
+ }
563
+
564
+ set activeItems(itemList: readonly T[]) {
565
+ this.wrapped.activeItems = this.findMonacoItemReferences(this.wrapped.items, itemList);
566
+ }
567
+
568
+ get activeItems(): readonly (T)[] {
569
+ return this.wrapped.activeItems.map(item => item.item);
570
+ }
571
+
572
+ set selectedItems(itemList: readonly T[]) {
573
+ this.wrapped.selectedItems = this.findMonacoItemReferences(this.wrapped.items, itemList);
574
+ }
575
+
576
+ get selectedItems(): readonly (T)[] {
577
+ return this.wrapped.selectedItems.map(item => item.item);
578
+ }
579
+
580
+ readonly onDidAccept: Event<{ inBackground: boolean }> = this.wrapped.onDidAccept;
581
+ readonly onDidChangeValue: Event<string> = this.wrapped.onDidChangeValue;
582
+
583
+ // need to cast because of vscode issue https://github.com/microsoft/vscode/issues/190584
584
+ readonly onDidTriggerButton: Event<QuickInputButton> = this.wrapped.onDidTriggerButton as Event<QuickInputButton>;
585
+ readonly onDidTriggerItemButton: Event<QuickPickItemButtonEvent<T>> =
586
+ Event.map(this.wrapped.onDidTriggerItemButton, (evt: IQuickPickItemButtonEvent<MonacoQuickPickItem<T>>) => ({
587
+ item: evt.item.item,
588
+ button: evt.button
589
+ })) as Event<QuickPickItemButtonEvent<T>>;
590
+ readonly onDidChangeActive: Event<T[]> = Event.map(
591
+ this.wrapped.onDidChangeActive,
592
+ (items: MonacoQuickPickItem<T>[]) => items.map(item => item.item));
593
+ readonly onDidChangeSelection: Event<T[]> = Event.map(
594
+ this.wrapped.onDidChangeSelection, (items: MonacoQuickPickItem<T>[]) => items.map(item => item.item));
595
+
596
+ /**
597
+ * Monaco doesn't check for deep equality when setting the `activeItems` or `selectedItems`.
598
+ * Instead we have to find the references of the monaco wrappers that contain the selected/active items
599
+ */
600
+ protected findMonacoItemReferences(source: readonly (MonacoQuickPickItem<T> | IQuickPickSeparator)[], items: readonly QuickPickItem[]): MonacoQuickPickItem<T>[] {
601
+ const monacoReferences: MonacoQuickPickItem<T>[] = [];
602
+ for (const item of items) {
603
+ for (const wrappedItem of source) {
604
+ if (wrappedItem instanceof MonacoQuickPickItem && wrappedItem.item === item) {
605
+ monacoReferences.push(wrappedItem);
606
+ }
607
+ }
608
+ }
609
+ return monacoReferences;
610
+ }
611
+ }
612
+
613
+ export class MonacoQuickPickItem<T extends QuickPickItem> implements IQuickPickItem {
614
+ readonly type?: 'item';
615
+ readonly id?: string;
616
+ readonly label: string;
617
+ readonly meta?: string;
618
+ readonly ariaLabel?: string;
619
+ readonly description?: string;
620
+ readonly detail?: string;
621
+ readonly keybinding?: ResolvedKeybinding;
622
+ readonly iconClasses?: string[];
623
+ buttons?: IQuickInputButton[];
624
+ readonly alwaysShow?: boolean;
625
+ readonly highlights?: QuickPickItemHighlights;
626
+
627
+ constructor(readonly item: T, kbRegistry: KeybindingRegistry) {
628
+ this.type = item.type;
629
+ this.id = item.id;
630
+ this.label = item.label;
631
+ this.meta = item.meta;
632
+ this.ariaLabel = item.ariaLabel;
633
+ this.description = item.description;
634
+ this.detail = item.detail;
635
+ this.keybinding = item.keySequence ? new MonacoResolvedKeybinding(item.keySequence, kbRegistry) : undefined;
636
+ this.iconClasses = item.iconClasses;
637
+ this.buttons = item.buttons;
638
+ this.alwaysShow = item.alwaysShow;
639
+ this.highlights = item.highlights;
640
+ }
641
+
642
+ accept(): void {
643
+ if (this.item.execute) {
644
+ this.item.execute();
645
+ }
646
+ }
647
+ }