@theia/core 1.77.0-next.47 → 1.77.0-next.56

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 (297) hide show
  1. package/lib/browser/breadcrumbs/breadcrumbs-renderer.js +1 -1
  2. package/lib/browser/breadcrumbs/breadcrumbs-renderer.js.map +1 -1
  3. package/lib/browser/catalog.json +27 -0
  4. package/lib/browser/color-application-contribution.d.ts +1 -1
  5. package/lib/browser/color-application-contribution.d.ts.map +1 -1
  6. package/lib/browser/color-registry.d.ts +1 -1
  7. package/lib/browser/color-registry.d.ts.map +1 -1
  8. package/lib/browser/common-frontend-contribution.js +2 -2
  9. package/lib/browser/common-frontend-contribution.js.map +1 -1
  10. package/lib/browser/common-frontend-contribution.spec.js +2 -1
  11. package/lib/browser/common-frontend-contribution.spec.js.map +1 -1
  12. package/lib/browser/components/card.d.ts +1 -1
  13. package/lib/browser/components/card.d.ts.map +1 -1
  14. package/lib/browser/components/card.js +3 -2
  15. package/lib/browser/components/card.js.map +1 -1
  16. package/lib/browser/connection-status-service.spec.js +2 -1
  17. package/lib/browser/connection-status-service.spec.js.map +1 -1
  18. package/lib/browser/context-key-service.d.ts +11 -0
  19. package/lib/browser/context-key-service.d.ts.map +1 -1
  20. package/lib/browser/context-key-service.js +7 -0
  21. package/lib/browser/context-key-service.js.map +1 -1
  22. package/lib/browser/decorations-service.spec.js +2 -1
  23. package/lib/browser/decorations-service.spec.js.map +1 -1
  24. package/lib/browser/dialogs/react-dialog.spec.js +2 -1
  25. package/lib/browser/dialogs/react-dialog.spec.js.map +1 -1
  26. package/lib/browser/diff-uris.js +1 -1
  27. package/lib/browser/diff-uris.js.map +1 -1
  28. package/lib/browser/endpoint.js +2 -1
  29. package/lib/browser/endpoint.js.map +1 -1
  30. package/lib/browser/endpoint.spec.js +2 -1
  31. package/lib/browser/endpoint.spec.js.map +1 -1
  32. package/lib/browser/keybinding.js +2 -2
  33. package/lib/browser/keybinding.js.map +1 -1
  34. package/lib/browser/keybinding.spec.js +3 -3
  35. package/lib/browser/keybinding.spec.js.map +1 -1
  36. package/lib/browser/keyboard/browser-keyboard-layout-provider.spec.js +3 -3
  37. package/lib/browser/keyboard/browser-keyboard-layout-provider.spec.js.map +1 -1
  38. package/lib/browser/keyboard/keyboard-layout-service.spec.js +3 -3
  39. package/lib/browser/keyboard/keyboard-layout-service.spec.js.map +1 -1
  40. package/lib/browser/keyboard/keys.spec.js +4 -3
  41. package/lib/browser/keyboard/keys.spec.js.map +1 -1
  42. package/lib/browser/label-provider.d.ts.map +1 -1
  43. package/lib/browser/label-provider.js +5 -3
  44. package/lib/browser/label-provider.js.map +1 -1
  45. package/lib/browser/label-provider.spec.js +2 -1
  46. package/lib/browser/label-provider.spec.js.map +1 -1
  47. package/lib/browser/markdown-rendering/markdown-link-handler.js +2 -1
  48. package/lib/browser/markdown-rendering/markdown-link-handler.js.map +1 -1
  49. package/lib/browser/markdown-rendering/markdown-renderer.d.ts +1 -1
  50. package/lib/browser/markdown-rendering/markdown-renderer.d.ts.map +1 -1
  51. package/lib/browser/markdown-rendering/markdown-renderer.js +4 -4
  52. package/lib/browser/markdown-rendering/markdown-renderer.js.map +1 -1
  53. package/lib/browser/markdown-rendering/markdown.js +2 -1
  54. package/lib/browser/markdown-rendering/markdown.js.map +1 -1
  55. package/lib/browser/markdown-rendering/markdown.spec.js +2 -1
  56. package/lib/browser/markdown-rendering/markdown.spec.js.map +1 -1
  57. package/lib/browser/menu/menu.spec.js +2 -1
  58. package/lib/browser/menu/menu.spec.js.map +1 -1
  59. package/lib/browser/opener-service.spec.js +3 -2
  60. package/lib/browser/opener-service.spec.js.map +1 -1
  61. package/lib/browser/perspective-service.spec.js +2 -1
  62. package/lib/browser/perspective-service.spec.js.map +1 -1
  63. package/lib/browser/preferences/preference-proxy.spec.js +2 -1
  64. package/lib/browser/preferences/preference-proxy.spec.js.map +1 -1
  65. package/lib/browser/preferences/preference-schema-provider.spec.js +2 -1
  66. package/lib/browser/preferences/preference-schema-provider.spec.js.map +1 -1
  67. package/lib/browser/preferences/preference-service.spec.js +2 -1
  68. package/lib/browser/preferences/preference-service.spec.js.map +1 -1
  69. package/lib/browser/preferences/preference-validation-service.spec.js +78 -77
  70. package/lib/browser/preferences/preference-validation-service.spec.js.map +1 -1
  71. package/lib/browser/quick-input/quick-command-service.d.ts +10 -1
  72. package/lib/browser/quick-input/quick-command-service.d.ts.map +1 -1
  73. package/lib/browser/quick-input/quick-command-service.js +31 -6
  74. package/lib/browser/quick-input/quick-command-service.js.map +1 -1
  75. package/lib/browser/quick-input/quick-command-service.spec.d.ts +2 -0
  76. package/lib/browser/quick-input/quick-command-service.spec.d.ts.map +1 -0
  77. package/lib/browser/quick-input/quick-command-service.spec.js +130 -0
  78. package/lib/browser/quick-input/quick-command-service.spec.js.map +1 -0
  79. package/lib/browser/quick-input/quick-help-service.js +1 -1
  80. package/lib/browser/quick-input/quick-help-service.js.map +1 -1
  81. package/lib/browser/quick-input/quick-input-service.spec.js +2 -1
  82. package/lib/browser/quick-input/quick-input-service.spec.js.map +1 -1
  83. package/lib/browser/quick-input/quick-pick-service-impl.d.ts +6 -6
  84. package/lib/browser/quick-input/quick-pick-service-impl.d.ts.map +1 -1
  85. package/lib/browser/quick-input/quick-view-service.spec.js +2 -1
  86. package/lib/browser/quick-input/quick-view-service.spec.js.map +1 -1
  87. package/lib/browser/secondary-window-handler.d.ts +4 -4
  88. package/lib/browser/secondary-window-handler.d.ts.map +1 -1
  89. package/lib/browser/shell/application-shell.js +1 -1
  90. package/lib/browser/shell/application-shell.js.map +1 -1
  91. package/lib/browser/shell/application-shell.spec.js +2 -1
  92. package/lib/browser/shell/application-shell.spec.js.map +1 -1
  93. package/lib/browser/shell/shell-layout-restorer.spec.js +2 -1
  94. package/lib/browser/shell/shell-layout-restorer.spec.js.map +1 -1
  95. package/lib/browser/shell/side-panel-toolbar.d.ts +1 -1
  96. package/lib/browser/shell/side-panel-toolbar.d.ts.map +1 -1
  97. package/lib/browser/shell/sidebar-menu-widget.js +1 -1
  98. package/lib/browser/shell/sidebar-menu-widget.js.map +1 -1
  99. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.js +1 -1
  100. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.js.map +1 -1
  101. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.spec.js +2 -1
  102. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.spec.js.map +1 -1
  103. package/lib/browser/shell/tab-bars.js +2 -1
  104. package/lib/browser/shell/tab-bars.js.map +1 -1
  105. package/lib/browser/status-bar/status-bar.js +1 -1
  106. package/lib/browser/status-bar/status-bar.js.map +1 -1
  107. package/lib/browser/storage-service.spec.js +2 -1
  108. package/lib/browser/storage-service.spec.js.map +1 -1
  109. package/lib/browser/tooltip-service.js +1 -1
  110. package/lib/browser/tooltip-service.js.map +1 -1
  111. package/lib/browser/tree/tree-consistency.spec.js +1 -1
  112. package/lib/browser/tree/tree-consistency.spec.js.map +1 -1
  113. package/lib/browser/tree/tree-container.spec.js +6 -5
  114. package/lib/browser/tree/tree-container.spec.js.map +1 -1
  115. package/lib/browser/tree/tree-iterator.js +1 -1
  116. package/lib/browser/tree/tree-iterator.js.map +1 -1
  117. package/lib/browser/tree/tree-model.js +2 -2
  118. package/lib/browser/tree/tree-model.js.map +1 -1
  119. package/lib/browser/tree/tree-view-welcome-widget.js +1 -1
  120. package/lib/browser/tree/tree-view-welcome-widget.js.map +1 -1
  121. package/lib/browser/tree/tree-widget.d.ts +2 -2
  122. package/lib/browser/tree/tree-widget.d.ts.map +1 -1
  123. package/lib/browser/tree/tree-widget.js +1 -1
  124. package/lib/browser/tree/tree-widget.js.map +1 -1
  125. package/lib/browser/tree/tree.spec.js +2 -1
  126. package/lib/browser/tree/tree.spec.js.map +1 -1
  127. package/lib/browser/user-working-directory-provider.js +1 -1
  128. package/lib/browser/user-working-directory-provider.js.map +1 -1
  129. package/lib/browser/widgets/react-renderer.js +1 -1
  130. package/lib/browser/widgets/react-renderer.js.map +1 -1
  131. package/lib/browser/widgets/react-widget.js +1 -1
  132. package/lib/browser/widgets/react-widget.js.map +1 -1
  133. package/lib/browser/widgets/select-component.js +4 -3
  134. package/lib/browser/widgets/select-component.js.map +1 -1
  135. package/lib/browser/widgets/select-component.spec.js +3 -2
  136. package/lib/browser/widgets/select-component.spec.js.map +1 -1
  137. package/lib/browser/widgets/widget.js +1 -1
  138. package/lib/browser/widgets/widget.js.map +1 -1
  139. package/lib/common/buffer.js +3 -2
  140. package/lib/common/buffer.js.map +1 -1
  141. package/lib/common/cancellation.js.map +1 -1
  142. package/lib/common/command.spec.js +2 -1
  143. package/lib/common/command.spec.js.map +1 -1
  144. package/lib/common/disposable.spec.js +3 -2
  145. package/lib/common/disposable.spec.js.map +1 -1
  146. package/lib/common/encoding-service.js +2 -2
  147. package/lib/common/encoding-service.js.map +1 -1
  148. package/lib/common/event.d.ts +1 -1
  149. package/lib/common/event.d.ts.map +1 -1
  150. package/lib/common/event.js +0 -1
  151. package/lib/common/event.js.map +1 -1
  152. package/lib/common/file-uri.js +2 -1
  153. package/lib/common/file-uri.js.map +1 -1
  154. package/lib/common/fuzzy-search.js +1 -1
  155. package/lib/common/fuzzy-search.js.map +1 -1
  156. package/lib/common/glob.d.ts.map +1 -1
  157. package/lib/common/glob.js +9 -15
  158. package/lib/common/glob.js.map +1 -1
  159. package/lib/common/index.js +1 -1
  160. package/lib/common/index.js.map +1 -1
  161. package/lib/common/keys.js +1 -1
  162. package/lib/common/keys.js.map +1 -1
  163. package/lib/common/message-rpc/channel.spec.js +3 -2
  164. package/lib/common/message-rpc/channel.spec.js.map +1 -1
  165. package/lib/common/messaging/proxy-factory.js +2 -2
  166. package/lib/common/messaging/proxy-factory.js.map +1 -1
  167. package/lib/common/messaging/proxy-factory.spec.js +2 -1
  168. package/lib/common/messaging/proxy-factory.spec.js.map +1 -1
  169. package/lib/common/messaging/web-socket-channel.d.ts +1 -1
  170. package/lib/common/messaging/web-socket-channel.d.ts.map +1 -1
  171. package/lib/common/path.spec.js +2 -1
  172. package/lib/common/path.spec.js.map +1 -1
  173. package/lib/common/performance/stopwatch.spec.js +2 -1
  174. package/lib/common/performance/stopwatch.spec.js.map +1 -1
  175. package/lib/common/preferences/preference-schema-service.d.ts +2 -2
  176. package/lib/common/preferences/preference-schema-service.d.ts.map +1 -1
  177. package/lib/common/preferences/preference-service.js +1 -1
  178. package/lib/common/preferences/preference-service.js.map +1 -1
  179. package/lib/common/promise-util.spec.js +2 -1
  180. package/lib/common/promise-util.spec.js.map +1 -1
  181. package/lib/common/quick-pick-service.d.ts +5 -0
  182. package/lib/common/quick-pick-service.d.ts.map +1 -1
  183. package/lib/common/quick-pick-service.js +2 -1
  184. package/lib/common/quick-pick-service.js.map +1 -1
  185. package/lib/common/reference.spec.js +2 -1
  186. package/lib/common/reference.spec.js.map +1 -1
  187. package/lib/common/resource.js +1 -1
  188. package/lib/common/resource.js.map +1 -1
  189. package/lib/common/selection-service.spec.js +2 -1
  190. package/lib/common/selection-service.spec.js.map +1 -1
  191. package/lib/common/selection.js +2 -1
  192. package/lib/common/selection.js.map +1 -1
  193. package/lib/common/stream.d.ts.map +1 -1
  194. package/lib/common/stream.js +2 -1
  195. package/lib/common/stream.js.map +1 -1
  196. package/lib/common/strings.d.ts.map +1 -1
  197. package/lib/common/strings.js +1 -2
  198. package/lib/common/strings.js.map +1 -1
  199. package/lib/common/test/mock-resource-provider.js +1 -1
  200. package/lib/common/test/mock-resource-provider.js.map +1 -1
  201. package/lib/common/types.spec.js +2 -1
  202. package/lib/common/types.spec.js.map +1 -1
  203. package/lib/common/uri-command-handler.js +4 -3
  204. package/lib/common/uri-command-handler.js.map +1 -1
  205. package/lib/common/uri-command-handler.spec.js +3 -2
  206. package/lib/common/uri-command-handler.spec.js.map +1 -1
  207. package/lib/common/uri.spec.js +3 -2
  208. package/lib/common/uri.spec.js.map +1 -1
  209. package/lib/electron-browser/window/window-zoom-action-bar.js +2 -1
  210. package/lib/electron-browser/window/window-zoom-action-bar.js.map +1 -1
  211. package/lib/electron-main/electron-api-main.js +2 -2
  212. package/lib/electron-main/electron-api-main.js.map +1 -1
  213. package/lib/electron-main/electron-main-application.js +2 -2
  214. package/lib/electron-main/electron-main-application.js.map +1 -1
  215. package/lib/electron-node/hosting/electron-backend-hosting-module.spec.js +2 -1
  216. package/lib/electron-node/hosting/electron-backend-hosting-module.spec.js.map +1 -1
  217. package/lib/electron-node/keyboard/electron-keyboard-layout-provider.js +1 -1
  218. package/lib/electron-node/keyboard/electron-keyboard-layout-provider.js.map +1 -1
  219. package/lib/electron-node/token/electron-token-validator.js +2 -2
  220. package/lib/electron-node/token/electron-token-validator.js.map +1 -1
  221. package/lib/node/backend-application.d.ts +1 -1
  222. package/lib/node/backend-application.d.ts.map +1 -1
  223. package/lib/node/backend-application.js +7 -7
  224. package/lib/node/backend-application.js.map +1 -1
  225. package/lib/node/backend-application.spec.js +1 -1
  226. package/lib/node/backend-application.spec.js.map +1 -1
  227. package/lib/node/bundled-resource-provider.js +4 -4
  228. package/lib/node/bundled-resource-provider.js.map +1 -1
  229. package/lib/node/bundled-resource-provider.spec.js +5 -4
  230. package/lib/node/bundled-resource-provider.spec.js.map +1 -1
  231. package/lib/node/cli.d.ts +1 -1
  232. package/lib/node/cli.d.ts.map +1 -1
  233. package/lib/node/cli.js +2 -2
  234. package/lib/node/cli.js.map +1 -1
  235. package/lib/node/cli.spec.js +3 -2
  236. package/lib/node/cli.spec.js.map +1 -1
  237. package/lib/node/console-logger-server.js +1 -1
  238. package/lib/node/console-logger-server.js.map +1 -1
  239. package/lib/node/env-variables/env-variables-server.js +1 -1
  240. package/lib/node/env-variables/env-variables-server.js.map +1 -1
  241. package/lib/node/environment-utils.spec.js +2 -1
  242. package/lib/node/environment-utils.spec.js.map +1 -1
  243. package/lib/node/file-uri.spec.js +4 -3
  244. package/lib/node/file-uri.spec.js.map +1 -1
  245. package/lib/node/filesystem-locking.js +1 -1
  246. package/lib/node/filesystem-locking.js.map +1 -1
  247. package/lib/node/hosting/browser-connection-token.js +2 -2
  248. package/lib/node/hosting/browser-connection-token.js.map +1 -1
  249. package/lib/node/i18n/localization-contribution.js +1 -1
  250. package/lib/node/i18n/localization-contribution.js.map +1 -1
  251. package/lib/node/key-store-server.js +1 -1
  252. package/lib/node/key-store-server.js.map +1 -1
  253. package/lib/node/logger-cli-contribution.js +2 -2
  254. package/lib/node/logger-cli-contribution.js.map +1 -1
  255. package/lib/node/logger-cli-contribution.spec.js +17 -16
  256. package/lib/node/logger-cli-contribution.spec.js.map +1 -1
  257. package/lib/node/messaging/ipc-connection-provider.js +2 -2
  258. package/lib/node/messaging/ipc-connection-provider.js.map +1 -1
  259. package/lib/node/process-utils.js +1 -1
  260. package/lib/node/process-utils.js.map +1 -1
  261. package/lib/node/process-utils.spec.js +2 -1
  262. package/lib/node/process-utils.spec.js.map +1 -1
  263. package/lib/node/request/backend-request-facade.spec.js +2 -1
  264. package/lib/node/request/backend-request-facade.spec.js.map +1 -1
  265. package/lib/node/setting-service.spec.js +2 -1
  266. package/lib/node/setting-service.spec.js.map +1 -1
  267. package/package.json +4 -4
  268. package/src/browser/common-frontend-contribution.ts +1 -1
  269. package/src/browser/components/card.tsx +1 -1
  270. package/src/browser/context-key-service.ts +15 -0
  271. package/src/browser/keybinding.ts +1 -1
  272. package/src/browser/label-provider.ts +3 -1
  273. package/src/browser/markdown-rendering/markdown-renderer.ts +1 -1
  274. package/src/browser/preferences/preference-validation-service.spec.ts +1 -1
  275. package/src/browser/quick-input/quick-command-service.spec.ts +159 -0
  276. package/src/browser/quick-input/quick-command-service.ts +36 -9
  277. package/src/browser/quick-input/quick-help-service.ts +1 -1
  278. package/src/browser/tree/tree-container.spec.ts +1 -1
  279. package/src/browser/tree/tree-iterator.ts +1 -1
  280. package/src/browser/tree/tree-model.ts +2 -2
  281. package/src/browser/tree/tree-widget.tsx +2 -2
  282. package/src/common/cancellation.ts +1 -1
  283. package/src/common/disposable.spec.ts +1 -1
  284. package/src/common/event.ts +1 -2
  285. package/src/common/glob.ts +13 -30
  286. package/src/common/json-schema.ts +1 -1
  287. package/src/common/keys.ts +1 -1
  288. package/src/common/message-rpc/channel.spec.ts +1 -1
  289. package/src/common/messaging/proxy-factory.ts +2 -2
  290. package/src/common/quick-pick-service.ts +5 -0
  291. package/src/common/stream.ts +4 -3
  292. package/src/common/strings.ts +2 -5
  293. package/src/common/ternary-search-tree.ts +1 -1
  294. package/src/common/uri-command-handler.ts +2 -2
  295. package/src/node/backend-application.ts +1 -1
  296. package/src/node/cli.ts +1 -1
  297. package/src/node/logger-cli-contribution.spec.ts +1 -1
@@ -0,0 +1,159 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2026 EclipseSource 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 { enableJSDOM } from '../test/jsdom';
18
+ let disableJSDOM = enableJSDOM();
19
+
20
+ import { FrontendApplicationConfigProvider } from '../frontend-application-config-provider';
21
+ FrontendApplicationConfigProvider.set({});
22
+
23
+ import * as chai from 'chai';
24
+ import { Container } from 'inversify';
25
+ import { CancellationToken, CommandRegistry, Emitter } from '../../common';
26
+ import { CorePreferences } from '../../common/core-preferences';
27
+ import { ContextKeyService, ContextKeyServiceDummyImpl } from '../context-key-service';
28
+ import { KeybindingRegistry } from '../keybinding';
29
+ import { QuickAccessRegistry } from './quick-access';
30
+ import { QuickCommandService } from './quick-command-service';
31
+ import { QuickInputService, QuickPickItem } from './quick-input-service';
32
+
33
+ disableJSDOM();
34
+
35
+ const expect = chai.expect;
36
+
37
+ class RecordingContextKeyService extends ContextKeyServiceDummyImpl {
38
+ activeContext: unknown;
39
+
40
+ override withContext<T>(context: unknown, callback: () => T): T {
41
+ const previous = this.activeContext;
42
+ this.activeContext = context;
43
+ try {
44
+ return callback();
45
+ } finally {
46
+ this.activeContext = previous;
47
+ }
48
+ }
49
+ }
50
+
51
+ describe('quick-command-service', () => {
52
+
53
+ let editor: HTMLElement;
54
+ let quickInput: HTMLInputElement;
55
+ let contextKeyService: RecordingContextKeyService;
56
+ let commandRegistry: CommandRegistry;
57
+ let onHideEmitter: Emitter<void>;
58
+ let quickInputService: { previousFocusElement?: HTMLElement, onHide: Emitter<void>['event'] };
59
+ let service: QuickCommandService;
60
+
61
+ before(() => {
62
+ disableJSDOM = enableJSDOM();
63
+ });
64
+
65
+ after(() => {
66
+ disableJSDOM();
67
+ });
68
+
69
+ beforeEach(() => {
70
+ editor = document.createElement('div');
71
+ editor.tabIndex = 0;
72
+ quickInput = document.createElement('input');
73
+ document.body.append(editor, quickInput);
74
+ // Focus has moved to the quick input, as it does while the palette is open.
75
+ quickInput.focus();
76
+
77
+ contextKeyService = new RecordingContextKeyService();
78
+ commandRegistry = new CommandRegistry({ getContributions: () => [] });
79
+ onHideEmitter = new Emitter<void>();
80
+ quickInputService = { previousFocusElement: editor, onHide: onHideEmitter.event };
81
+
82
+ const container = new Container();
83
+ container.bind(ContextKeyService).toConstantValue(contextKeyService);
84
+ container.bind(CommandRegistry).toConstantValue(commandRegistry);
85
+ container.bind(CorePreferences).toConstantValue(<CorePreferences>{ 'workbench.commandPalette.history': 50 });
86
+ container.bind(QuickAccessRegistry).toConstantValue(<QuickAccessRegistry>{});
87
+ container.bind(KeybindingRegistry).toConstantValue(<KeybindingRegistry><unknown>{ getKeybindingsForCommand: () => [] });
88
+ container.bind(QuickInputService).toConstantValue(<QuickInputService><unknown>quickInputService);
89
+ container.bind(QuickCommandService).toSelf();
90
+ service = container.get(QuickCommandService);
91
+ });
92
+
93
+ afterEach(() => {
94
+ editor.remove();
95
+ quickInput.remove();
96
+ onHideEmitter.dispose();
97
+ });
98
+
99
+ function inEditorContext(): boolean {
100
+ return contextKeyService.activeContext === editor;
101
+ }
102
+
103
+ function picks(): QuickPickItem[] {
104
+ return service.getPicks('', CancellationToken.None).filter((pick): pick is QuickPickItem => pick.type !== 'separator');
105
+ }
106
+
107
+ it('evaluates command enablement against the element focused before the quick input opened', () => {
108
+ commandRegistry.registerCommand({ id: 'test.editorOnly', label: 'Editor Only' }, { execute: () => { }, isEnabled: inEditorContext });
109
+
110
+ expect(picks().map(pick => pick.label)).to.deep.equal(['Editor Only']);
111
+ });
112
+
113
+ it('evaluates item state against the element focused before the quick input opened', () => {
114
+ commandRegistry.registerCommand({ id: 'test.toggle', label: 'Toggle' }, { execute: () => { }, isEnabled: inEditorContext, isToggled: inEditorContext });
115
+
116
+ const [item] = picks();
117
+ expect(item.alwaysShow).to.be.true;
118
+ expect(item.iconClasses).to.not.be.undefined;
119
+ });
120
+
121
+ it('evaluates pushed command contexts against the element focused before the quick input opened', () => {
122
+ contextKeyService.match = () => inEditorContext();
123
+ commandRegistry.registerCommand({ id: 'test.when', label: 'When' }, { execute: () => { } });
124
+ service.pushCommandContext('test.when', 'editorFocus');
125
+
126
+ expect(picks().map(pick => pick.label)).to.deep.equal(['When']);
127
+ });
128
+
129
+ it('restores focus to the element focused before the quick input opened on execute', () => {
130
+ commandRegistry.registerCommand({ id: 'test.command', label: 'Command' }, { execute: () => { } });
131
+
132
+ picks()[0].execute!();
133
+
134
+ expect(document.activeElement).to.equal(editor);
135
+ });
136
+
137
+ it('falls back to the active element when items are created without a reset', () => {
138
+ commandRegistry.registerCommand({ id: 'test.command', label: 'Command' }, { execute: () => { } });
139
+ const item = service.toItem({ id: 'test.command', label: 'Command' });
140
+ editor.focus();
141
+
142
+ item.execute!();
143
+
144
+ expect(document.activeElement).to.equal(quickInput);
145
+ });
146
+
147
+ it('forgets the context element when the quick input is hidden', () => {
148
+ commandRegistry.registerCommand({ id: 'test.command', label: 'Command' }, { execute: () => { } });
149
+ service.reset();
150
+ onHideEmitter.fire();
151
+
152
+ const item = service.toItem({ id: 'test.command', label: 'Command' });
153
+ editor.focus();
154
+ item.execute!();
155
+
156
+ expect(document.activeElement).to.equal(quickInput);
157
+ });
158
+
159
+ });
@@ -14,13 +14,13 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
- import { inject, injectable } from 'inversify';
17
+ import { inject, injectable, optional, postConstruct } from 'inversify';
18
18
  import { KeybindingRegistry } from '../keybinding';
19
19
  import { Disposable, Command, CommandRegistry, CancellationToken, nls } from '../../common';
20
20
  import { ContextKeyService } from '../context-key-service';
21
21
  import { CorePreferences } from '../../common/core-preferences';
22
22
  import { QuickAccessContribution, QuickAccessProvider, QuickAccessRegistry } from './quick-access';
23
- import { filterItems, QuickPickItem, QuickPicks } from './quick-input-service';
23
+ import { filterItems, QuickInputService, QuickPickItem, QuickPicks } from './quick-input-service';
24
24
  import { KeySequence } from '../keys';
25
25
  import { codiconArray } from '../widgets';
26
26
 
@@ -56,6 +56,9 @@ export class QuickCommandService implements QuickAccessContribution, QuickAccess
56
56
  @inject(KeybindingRegistry)
57
57
  protected readonly keybindingRegistry: KeybindingRegistry;
58
58
 
59
+ @inject(QuickInputService) @optional()
60
+ protected readonly quickInputService: QuickInputService | undefined;
61
+
59
62
  // The list of exempted commands not to be displayed in the recently used list.
60
63
  readonly exemptedCommands: Command[] = [
61
64
  CLEAR_COMMAND_HISTORY,
@@ -64,6 +67,17 @@ export class QuickCommandService implements QuickAccessContribution, QuickAccess
64
67
  private recentItems: QuickPickItem[] = [];
65
68
  private otherItems: QuickPickItem[] = [];
66
69
 
70
+ /**
71
+ * The element that was focused when the quick input was opened.
72
+ * Commands are evaluated against its context, since focus moves to the quick input while the palette is open.
73
+ */
74
+ protected commandContextElement: HTMLElement | undefined;
75
+
76
+ @postConstruct()
77
+ protected init(): void {
78
+ this.quickInputService?.onHide(() => this.commandContextElement = undefined);
79
+ }
80
+
67
81
  registerQuickAccessProvider(): void {
68
82
  this.quickAccessRegistry.registerQuickAccessProvider({
69
83
  getInstance: () => this,
@@ -74,11 +88,12 @@ export class QuickCommandService implements QuickAccessContribution, QuickAccess
74
88
  }
75
89
 
76
90
  reset(): void {
77
- const { recent, other } = this.getCommands();
78
- this.recentItems = [];
79
- this.otherItems = [];
80
- this.recentItems.push(...recent.map(command => this.toItem(command)));
81
- this.otherItems.push(...other.map(command => this.toItem(command)));
91
+ this.updateCommandContextElement();
92
+ this.withCommandContext(() => {
93
+ const { recent, other } = this.getCommands();
94
+ this.recentItems = recent.map(command => this.toItem(command));
95
+ this.otherItems = other.map(command => this.toItem(command));
96
+ });
82
97
  }
83
98
 
84
99
  getPicks(filter: string, token: CancellationToken): QuickPicks {
@@ -105,7 +120,8 @@ export class QuickCommandService implements QuickAccessContribution, QuickAccess
105
120
  toItem(command: Command): QuickPickItem {
106
121
  const label = (command.category) ? `${command.category}: ` + command.label! : command.label!;
107
122
  const iconClasses = this.getItemIconClasses(command);
108
- const activeElement = window.document.activeElement as HTMLElement;
123
+ const activeElement = window.document.activeElement;
124
+ const commandContextElement = this.commandContextElement ?? (activeElement instanceof HTMLElement ? activeElement : undefined);
109
125
 
110
126
  const originalLabel = command.originalLabel || command.label!;
111
127
  const originalCategory = command.originalCategory || command.category;
@@ -121,13 +137,24 @@ export class QuickCommandService implements QuickAccessContribution, QuickAccess
121
137
  alwaysShow: !!this.commandRegistry.getActiveHandler(command.id),
122
138
  keySequence: this.getKeybinding(command),
123
139
  execute: () => {
124
- activeElement.focus({ preventScroll: true });
140
+ commandContextElement?.focus({ preventScroll: true });
125
141
  this.commandRegistry.executeCommand(command.id);
126
142
  this.commandRegistry.addRecentCommand(command);
127
143
  }
128
144
  };
129
145
  }
130
146
 
147
+ protected updateCommandContextElement(): void {
148
+ // When the palette is opened directly, the picks are computed before the quick input is shown and focused.
149
+ const element = this.quickInputService?.previousFocusElement ?? window.document.activeElement;
150
+ this.commandContextElement = element instanceof HTMLElement ? element : undefined;
151
+ }
152
+
153
+ protected withCommandContext<T>(callback: () => T): T {
154
+ const element = this.commandContextElement;
155
+ return element?.isConnected ? this.contextKeyService.withContext(element, callback) : callback();
156
+ }
157
+
131
158
  private getKeybinding(command: Command): KeySequence | undefined {
132
159
  const keybindings = this.keybindingRegistry.getKeybindingsForCommand(command.id);
133
160
  if (!keybindings || keybindings.length === 0) {
@@ -60,7 +60,7 @@ export class QuickHelpService implements QuickAccessProvider, QuickAccessContrib
60
60
 
61
61
  for (const helpEntry of provider.helpEntries) {
62
62
  const prefix = helpEntry.prefix || provider.prefix;
63
- const label = prefix || '\u2026' /* ... */;
63
+ const label = prefix || '\u2026'; // ...
64
64
 
65
65
  (helpEntry.needsEditor ? editorProviders : globalProviders).push({
66
66
  label,
@@ -14,7 +14,7 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
- import * as assert from 'assert';
17
+ import assert from 'assert';
18
18
  import { Container } from 'inversify';
19
19
  import { createTreeContainer, isTreeServices } from './tree-container';
20
20
  import { TreeSearch } from './tree-search';
@@ -47,7 +47,7 @@ export abstract class AbstractTreeIterator implements TreeIterator, Iterable<Tre
47
47
  this.delegate = this.iterator(this.root);
48
48
  }
49
49
 
50
- // tslint:disable-next-line:typedef
50
+ // eslint-disable-next-line @theia/explicit-return-type
51
51
  [Symbol.iterator]() {
52
52
  return this.delegate;
53
53
  }
@@ -263,12 +263,12 @@ export class TreeModelImpl implements TreeModel, SelectionProvider<ReadonlyArray
263
263
  return this.tree.refresh();
264
264
  }
265
265
 
266
- // tslint:disable-next-line:typedef
266
+ // eslint-disable-next-line @theia/explicit-return-type
267
267
  get selectedNodes() {
268
268
  return this.selectionService.selectedNodes;
269
269
  }
270
270
 
271
- // tslint:disable-next-line:typedef
271
+ // eslint-disable-next-line @theia/explicit-return-type
272
272
  get onSelectionChanged() {
273
273
  return this.selectionService.onSelectionChanged;
274
274
  }
@@ -120,7 +120,7 @@ export interface TreeProps {
120
120
  /**
121
121
  * Props that are forwarded to the virtuoso list rendered. Defaults to `{}`.
122
122
  */
123
- readonly viewProps?: VirtuosoProps<unknown, unknown>;
123
+ readonly viewProps?: Omit<VirtuosoProps<unknown, unknown>, 'width' | 'height' | 'rows'>;
124
124
  }
125
125
 
126
126
  /**
@@ -1602,7 +1602,7 @@ export namespace TreeWidget {
1602
1602
  /**
1603
1603
  * Representation of the tree view properties.
1604
1604
  */
1605
- export interface ViewProps extends VirtuosoProps<unknown, unknown> {
1605
+ export interface ViewProps extends Omit<VirtuosoProps<unknown, unknown>, 'width' | 'height' | 'rows'> {
1606
1606
  /**
1607
1607
  * The width property.
1608
1608
  */
@@ -128,7 +128,7 @@ export class CancellationTokenSource {
128
128
  // before someone asks for the token
129
129
  this._token = CancellationToken.Cancelled;
130
130
  } else if (this._token !== CancellationToken.Cancelled) {
131
- (<MutableToken>this._token).cancel();
131
+ (this._token as MutableToken).cancel();
132
132
  }
133
133
  }
134
134
 
@@ -16,7 +16,7 @@
16
16
 
17
17
  import { expect, spy, use } from 'chai';
18
18
  import { DisposableCollection, Disposable } from './disposable';
19
- import * as spies from 'chai-spies';
19
+ import spies from 'chai-spies';
20
20
 
21
21
  use(spies);
22
22
 
@@ -166,8 +166,7 @@ class CallbackList implements Iterable<Callback> {
166
166
  }
167
167
  }
168
168
 
169
- // tslint:disable-next-line:typedef
170
- public [Symbol.iterator]() {
169
+ public [Symbol.iterator](): IterableIterator<Callback> {
171
170
  if (!this._callbacks) {
172
171
  return [][Symbol.iterator]();
173
172
  }
@@ -127,11 +127,8 @@ function parseRegExp(pattern: string): string {
127
127
  // Special case where we only have globstars
128
128
  if (segments.every(s => s === GLOBSTAR)) {
129
129
  regEx = '.*';
130
- }
131
-
132
- // Build regex over segments
133
- // tslint:disable-next-line:one-line
134
- else {
130
+ } else {
131
+ // Build regex over segments
135
132
  let previousSegmentWasGlobStar = false;
136
133
  segments.forEach((segment, index) => {
137
134
 
@@ -171,24 +168,15 @@ function parseRegExp(pattern: string): string {
171
168
  // range operator
172
169
  if (char === '-') {
173
170
  res = char;
174
- }
175
-
176
- // negation operator (only valid on first index in bracket)
177
- // tslint:disable-next-line:one-line
178
- else if ((char === '^' || char === '!') && !bracketVal) {
171
+ } else if ((char === '^' || char === '!') && !bracketVal) {
172
+ // negation operator (only valid on first index in bracket)
179
173
  res = '^';
180
- }
181
-
182
- // glob split matching is not allowed within character ranges
183
- // see http://man7.org/linux/man-pages/man7/glob.7.html
184
- // tslint:disable-next-line:one-line
185
- else if (char === GLOB_SPLIT) {
174
+ } else if (char === GLOB_SPLIT) {
175
+ // glob split matching is not allowed within character ranges
176
+ // see http://man7.org/linux/man-pages/man7/glob.7.html
186
177
  res = '';
187
- }
188
-
189
- // anything else gets escaped
190
- // tslint:disable-next-line:one-line
191
- else {
178
+ } else {
179
+ // anything else gets escaped
192
180
  res = strings.escapeRegExpCharacters(char);
193
181
  }
194
182
 
@@ -270,7 +258,7 @@ export type ParsedPattern = (path: string, basename?: string) => boolean;
270
258
 
271
259
  // The ParsedExpression returns a Promise iff hasSibling returns a Promise.
272
260
  // eslint-disable-next-line max-len
273
- export type ParsedExpression = (path: string, basename?: string, hasSibling?: (name: string) => boolean | Promise<boolean>) => string | Promise<string> /* the matching pattern */;
261
+ export type ParsedExpression = (path: string, basename?: string, hasSibling?: (name: string) => boolean | Promise<boolean>) => string | Promise<string>; // the matching pattern
274
262
 
275
263
  export interface IGlobOptions {
276
264
  /**
@@ -341,11 +329,8 @@ function parsePattern(arg1: string | IRelativePattern, options: IGlobOptions): P
341
329
  parsedPattern = trivia4and5(match[1].substring(1), pattern, true);
342
330
  } else if (match = T5.exec(trimForExclusions(pattern, options))!) { // common pattern: something/else just need equals check
343
331
  parsedPattern = trivia4and5(match[1], pattern, false);
344
- }
345
-
346
- // Otherwise convert to pattern
347
- // tslint:disable-next-line:one-line
348
- else {
332
+ } else {
333
+ // Otherwise convert to pattern
349
334
  parsedPattern = toRegExp(pattern);
350
335
  }
351
336
 
@@ -461,7 +446,7 @@ function toRegExp(pattern: string): ParsedStringPattern {
461
446
  * - character ranges (using [...])
462
447
  */
463
448
  export function match(pattern: string | IRelativePattern, path: string): boolean;
464
- export function match(expression: IExpression, path: string, hasSibling?: (name: string) => boolean): string /* the matching pattern */;
449
+ export function match(expression: IExpression, path: string, hasSibling?: (name: string) => boolean): string; // the matching pattern
465
450
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
466
451
  export function match(arg1: string | IExpression | IRelativePattern, path: string, hasSibling?: (name: string) => boolean): any {
467
452
  if (!arg1 || !path) {
@@ -593,7 +578,6 @@ function parsedExpression(expression: IExpression, options: IGlobOptions): Parse
593
578
  // eslint-disable-next-line @typescript-eslint/no-shadow
594
579
  const resultExpression: ParsedStringPattern = function (path: string, basename: string): string | Promise<string> {
595
580
  // eslint-disable-next-line @typescript-eslint/no-shadow
596
- // tslint:disable-next-line:one-variable-per-declaration
597
581
  for (let i = 0, n = parsedPatterns.length; i < n; i++) {
598
582
  // Pattern matches path
599
583
  const result = (<ParsedStringPattern>parsedPatterns[i])(path, basename);
@@ -707,7 +691,6 @@ function aggregateBasenameMatches(parsedPatterns: (ParsedStringPattern | ParsedE
707
691
  let patterns: string[];
708
692
  if (result) {
709
693
  patterns = [];
710
- // tslint:disable-next-line:one-variable-per-declaration
711
694
  for (let i = 0, n = basenames.length; i < n; i++) {
712
695
  patterns.push(result);
713
696
  }
@@ -26,7 +26,7 @@ export type JsonType = 'string' | 'array' | 'number' | 'integer' | 'object' | 'b
26
26
  // copied from https://github.com/Microsoft/vscode/blob/d4edb9abcc261846cabee6702715fe2914ae42cb/src/vs/base/common/jsonSchema.ts
27
27
 
28
28
  // Keep tab indent for easier comparison with the original file.
29
- /* eslint-disable @typescript-eslint/indent */
29
+ /* eslint-disable @stylistic/indent */
30
30
 
31
31
  /**
32
32
  * extended JSON schema
@@ -373,7 +373,7 @@ export namespace KeyCode {
373
373
  }
374
374
  }
375
375
 
376
- // tslint:disable-next-line: deprecation
376
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
377
377
  const keyCode = event.keyCode;
378
378
  if (keyCode) {
379
379
  const key = Key.getKey(keyCode);
@@ -15,7 +15,7 @@
15
15
  // *****************************************************************************
16
16
 
17
17
  import { assert, expect, spy, use } from 'chai';
18
- import * as spies from 'chai-spies';
18
+ import spies from 'chai-spies';
19
19
  import { Uint8ArrayReadBuffer, Uint8ArrayWriteBuffer } from './uint8-array-message-buffer';
20
20
  import { ChannelMultiplexer, ForwardingChannel, MessageProvider } from './channel';
21
21
  import { RpcProtocol } from './rpc-protocol';
@@ -333,7 +333,7 @@ export class JsonRpcProxyFactory<T extends object> extends RpcProxyFactory<T> {
333
333
 
334
334
  }
335
335
 
336
- // eslint-disable-next-line deprecation/deprecation
336
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
337
337
  decorate(injectable(), JsonRpcProxyFactory);
338
- // eslint-disable-next-line deprecation/deprecation
338
+ // eslint-disable-next-line @typescript-eslint/no-deprecated
339
339
  decorate(unmanaged(), JsonRpcProxyFactory, 0);
@@ -282,6 +282,11 @@ export interface QuickInputService {
282
282
  readonly backButton: QuickInputButton;
283
283
  readonly onShow: Event<void>;
284
284
  readonly onHide: Event<void>;
285
+ /**
286
+ * The element that had focus when the quick input was shown, while the quick input is showing.
287
+ * Items whose state depends on context keys should be evaluated against this element rather than the quick input itself.
288
+ */
289
+ readonly previousFocusElement?: HTMLElement;
285
290
  open(filter: string): void;
286
291
  createInputBox(): InputBox;
287
292
  input(options?: InputOptions, token?: CancellationToken): Promise<string | undefined>;
@@ -22,7 +22,8 @@
22
22
 
23
23
  /* eslint-disable max-len */
24
24
  /* eslint-disable no-null/no-null */
25
- /* eslint-disable @typescript-eslint/tslint/config */
25
+ /* eslint-disable @stylistic/brace-style */
26
+ /* eslint-disable @theia/explicit-return-type */
26
27
  /* eslint-disable @typescript-eslint/no-explicit-any */
27
28
 
28
29
  import { DisposableCollection, Disposable } from './disposable';
@@ -730,7 +731,7 @@ export function fileToStream(file: File): ReadableStream<BinaryBuffer> {
730
731
  try {
731
732
  while (true) {
732
733
  const { value, done } = await reader.read();
733
- if (done) {break;}
734
+ if (done) { break; }
734
735
 
735
736
  if (value?.byteLength) {
736
737
  await ws.write(BinaryBuffer.wrap(value));
@@ -740,7 +741,7 @@ export function fileToStream(file: File): ReadableStream<BinaryBuffer> {
740
741
  } catch (e: unknown) {
741
742
  try {
742
743
  await reader.cancel();
743
- } catch {}
744
+ } catch { }
744
745
 
745
746
  ws.error(e instanceof Error ? e : new Error(String(e)));
746
747
  }
@@ -76,11 +76,8 @@ function doEqualsIgnoreCase(a: string, b: string, stopAt = a.length): boolean {
76
76
  if (diff !== 0 && diff !== 32) {
77
77
  return false;
78
78
  }
79
- }
80
-
81
- // Any other charcode
82
- // tslint:disable-next-line:one-line
83
- else {
79
+ } else {
80
+ // Any other charcode
84
81
  if (String.fromCharCode(codeA).toLowerCase() !== String.fromCharCode(codeB).toLowerCase()) {
85
82
  return false;
86
83
  }
@@ -21,7 +21,7 @@
21
21
  // based on https://github.com/microsoft/vscode/blob/04c36be045a94fee58e5f8992d3e3fd980294a84/src/vs/base/common/map.ts#L251
22
22
 
23
23
  /* eslint-disable @typescript-eslint/no-explicit-any */
24
- /* eslint-disable @typescript-eslint/tslint/config */
24
+ /* eslint-disable @theia/explicit-return-type */
25
25
 
26
26
  import URI from './uri';
27
27
  import { CharCode } from './char-code';
@@ -133,7 +133,7 @@ export namespace UriAwareCommandHandler {
133
133
  * @returns a command handler for mono-select contexts that expects a `URI` as the first parameter of its methods.
134
134
  */
135
135
  export function MonoSelect(selectionService: SelectionService, handler: UriCommandHandler<URI>): UriAwareCommandHandler<URI> {
136
- /* eslint-disable-next-line deprecation/deprecation*/ // Safe to use when the generic and the options agree.
136
+ /* eslint-disable-next-line @typescript-eslint/no-deprecated */ // Safe to use when the generic and the options agree.
137
137
  return new UriAwareCommandHandler<URI>(selectionService, handler, { multi: false });
138
138
  }
139
139
 
@@ -141,7 +141,7 @@ export namespace UriAwareCommandHandler {
141
141
  * @returns a command handler for multi-select contexts that expects a `URI[]` as the first parameter of its methods.
142
142
  */
143
143
  export function MultiSelect(selectionService: SelectionService, handler: UriCommandHandler<URI[]>): UriAwareCommandHandler<URI[]> {
144
- /* eslint-disable-next-line deprecation/deprecation*/ // Safe to use when the generic and the options agree.
144
+ /* eslint-disable-next-line @typescript-eslint/no-deprecated */ // Safe to use when the generic and the options agree.
145
145
  return new UriAwareCommandHandler<URI[]>(selectionService, handler, { multi: true });
146
146
  }
147
147
  }
@@ -18,7 +18,7 @@ import * as dns from 'dns';
18
18
  import * as path from 'path';
19
19
  import * as http from 'http';
20
20
  import * as https from 'https';
21
- import * as express from 'express';
21
+ import express from 'express';
22
22
  import * as yargs from 'yargs';
23
23
  import * as fs from 'fs-extra';
24
24
  import { inject, named, injectable, type interfaces, postConstruct } from 'inversify';
package/src/node/cli.ts CHANGED
@@ -14,7 +14,7 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
- import * as yargs from 'yargs';
17
+ import yargs from 'yargs';
18
18
  import { inject, named, injectable } from 'inversify';
19
19
  import { ContributionProvider } from '../common/contribution-provider';
20
20
  import { MaybePromise } from '../common/types';
@@ -15,7 +15,7 @@
15
15
  // *****************************************************************************
16
16
 
17
17
  import { expect } from 'chai';
18
- import * as yargs from 'yargs';
18
+ import yargs from 'yargs';
19
19
  import * as temp from 'temp';
20
20
  import * as fs from 'fs';
21
21
  import { ContainerModule, Container } from 'inversify';