@theia/monaco 1.47.0-next.0 → 1.47.1
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.
- package/lib/browser/index.js +2 -11
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/markdown-renderer/monaco-markdown-renderer.d.ts +0 -4
- package/lib/browser/markdown-renderer/monaco-markdown-renderer.d.ts.map +1 -1
- package/lib/browser/markdown-renderer/monaco-markdown-renderer.js +18 -41
- package/lib/browser/markdown-renderer/monaco-markdown-renderer.js.map +1 -1
- package/lib/browser/monaco-bulk-edit-service.d.ts +1 -3
- package/lib/browser/monaco-bulk-edit-service.d.ts.map +1 -1
- package/lib/browser/monaco-bulk-edit-service.js +5 -13
- package/lib/browser/monaco-bulk-edit-service.js.map +1 -1
- package/lib/browser/monaco-color-registry.js +2 -7
- package/lib/browser/monaco-color-registry.js.map +1 -1
- package/lib/browser/monaco-command-registry.d.ts +1 -1
- package/lib/browser/monaco-command-registry.d.ts.map +1 -1
- package/lib/browser/monaco-command-registry.js +11 -16
- package/lib/browser/monaco-command-registry.js.map +1 -1
- package/lib/browser/monaco-command-service.d.ts +1 -6
- package/lib/browser/monaco-command-service.d.ts.map +1 -1
- package/lib/browser/monaco-command-service.js +20 -30
- package/lib/browser/monaco-command-service.js.map +1 -1
- package/lib/browser/monaco-command.d.ts +0 -6
- package/lib/browser/monaco-command.d.ts.map +1 -1
- package/lib/browser/monaco-command.js +19 -40
- package/lib/browser/monaco-command.js.map +1 -1
- package/lib/browser/monaco-context-key-service.d.ts +2 -2
- package/lib/browser/monaco-context-key-service.d.ts.map +1 -1
- package/lib/browser/monaco-context-key-service.js +11 -20
- package/lib/browser/monaco-context-key-service.js.map +1 -1
- package/lib/browser/monaco-context-menu.d.ts +4 -3
- package/lib/browser/monaco-context-menu.d.ts.map +1 -1
- package/lib/browser/monaco-context-menu.js +21 -19
- package/lib/browser/monaco-context-menu.js.map +1 -1
- package/lib/browser/monaco-diff-editor.d.ts +3 -3
- package/lib/browser/monaco-diff-editor.d.ts.map +1 -1
- package/lib/browser/monaco-diff-editor.js +2 -2
- package/lib/browser/monaco-diff-editor.js.map +1 -1
- package/lib/browser/monaco-diff-navigator-factory.d.ts +2 -3
- package/lib/browser/monaco-diff-navigator-factory.d.ts.map +1 -1
- package/lib/browser/monaco-diff-navigator-factory.js +7 -33
- package/lib/browser/monaco-diff-navigator-factory.js.map +1 -1
- package/lib/browser/monaco-editor-model.d.ts +4 -2
- package/lib/browser/monaco-editor-model.d.ts.map +1 -1
- package/lib/browser/monaco-editor-model.js +4 -1
- package/lib/browser/monaco-editor-model.js.map +1 -1
- package/lib/browser/monaco-editor-provider.d.ts +3 -20
- package/lib/browser/monaco-editor-provider.d.ts.map +1 -1
- package/lib/browser/monaco-editor-provider.js +37 -95
- package/lib/browser/monaco-editor-provider.js.map +1 -1
- package/lib/browser/monaco-editor-service.d.ts +7 -2
- package/lib/browser/monaco-editor-service.d.ts.map +1 -1
- package/lib/browser/monaco-editor-service.js +23 -31
- package/lib/browser/monaco-editor-service.js.map +1 -1
- package/lib/browser/monaco-editor.d.ts +4 -1
- package/lib/browser/monaco-editor.d.ts.map +1 -1
- package/lib/browser/monaco-editor.js +33 -26
- package/lib/browser/monaco-editor.js.map +1 -1
- package/lib/browser/monaco-formatting-conflicts.js +10 -18
- package/lib/browser/monaco-formatting-conflicts.js.map +1 -1
- package/lib/browser/monaco-frontend-application-contribution.d.ts +0 -6
- package/lib/browser/monaco-frontend-application-contribution.d.ts.map +1 -1
- package/lib/browser/monaco-frontend-application-contribution.js +18 -63
- package/lib/browser/monaco-frontend-application-contribution.js.map +1 -1
- package/lib/browser/monaco-frontend-module.d.ts.map +1 -1
- package/lib/browser/monaco-frontend-module.js +17 -8
- package/lib/browser/monaco-frontend-module.js.map +1 -1
- package/lib/browser/monaco-gotoline-quick-access.js +5 -16
- package/lib/browser/monaco-gotoline-quick-access.js.map +1 -1
- package/lib/browser/monaco-gotosymbol-quick-access.js +7 -18
- package/lib/browser/monaco-gotosymbol-quick-access.js.map +1 -1
- package/lib/browser/monaco-icon-registry.d.ts +1 -2
- package/lib/browser/monaco-icon-registry.d.ts.map +1 -1
- package/lib/browser/monaco-icon-registry.js +4 -7
- package/lib/browser/monaco-icon-registry.js.map +1 -1
- package/lib/browser/monaco-indexed-db.js +2 -7
- package/lib/browser/monaco-indexed-db.js.map +1 -1
- package/lib/browser/monaco-init.d.ts +5 -0
- package/lib/browser/monaco-init.d.ts.map +1 -0
- package/lib/browser/monaco-init.js +114 -0
- package/lib/browser/monaco-init.js.map +1 -0
- package/lib/browser/monaco-keybinding.js +17 -25
- package/lib/browser/monaco-keybinding.js.map +1 -1
- package/lib/browser/monaco-keycode-map.js +37 -37
- package/lib/browser/monaco-keycode-map.js.map +1 -1
- package/lib/browser/monaco-languages.js +10 -18
- package/lib/browser/monaco-languages.js.map +1 -1
- package/lib/browser/monaco-menu.js +4 -15
- package/lib/browser/monaco-menu.js.map +1 -1
- package/lib/browser/monaco-mime-service.js +3 -11
- package/lib/browser/monaco-mime-service.js.map +1 -1
- package/lib/browser/monaco-outline-contribution.js +6 -14
- package/lib/browser/monaco-outline-contribution.js.map +1 -1
- package/lib/browser/monaco-outline-decorator.js +2 -7
- package/lib/browser/monaco-outline-decorator.js.map +1 -1
- package/lib/browser/monaco-quick-access-registry.js +4 -12
- package/lib/browser/monaco-quick-access-registry.js.map +1 -1
- package/lib/browser/monaco-quick-input-service.d.ts +7 -9
- package/lib/browser/monaco-quick-input-service.d.ts.map +1 -1
- package/lib/browser/monaco-quick-input-service.js +116 -111
- package/lib/browser/monaco-quick-input-service.js.map +1 -1
- package/lib/browser/monaco-resolved-keybinding.d.ts +10 -10
- package/lib/browser/monaco-resolved-keybinding.d.ts.map +1 -1
- package/lib/browser/monaco-resolved-keybinding.js +16 -16
- package/lib/browser/monaco-resolved-keybinding.js.map +1 -1
- package/lib/browser/monaco-snippet-suggest-provider.js +4 -12
- package/lib/browser/monaco-snippet-suggest-provider.js.map +1 -1
- package/lib/browser/monaco-status-bar-contribution.js +5 -16
- package/lib/browser/monaco-status-bar-contribution.js.map +1 -1
- package/lib/browser/monaco-text-model-service.js +21 -29
- package/lib/browser/monaco-text-model-service.js.map +1 -1
- package/lib/browser/monaco-theming-service.js +8 -16
- package/lib/browser/monaco-theming-service.js.map +1 -1
- package/lib/browser/monaco-to-protocol-converter.js +2 -7
- package/lib/browser/monaco-to-protocol-converter.js.map +1 -1
- package/lib/browser/monaco-workspace.d.ts +1 -3
- package/lib/browser/monaco-workspace.d.ts.map +1 -1
- package/lib/browser/monaco-workspace.js +27 -35
- package/lib/browser/monaco-workspace.js.map +1 -1
- package/lib/browser/protocol-to-monaco-converter.js +2 -7
- package/lib/browser/protocol-to-monaco-converter.js.map +1 -1
- package/lib/browser/simple-monaco-editor.d.ts +1 -0
- package/lib/browser/simple-monaco-editor.d.ts.map +1 -1
- package/lib/browser/simple-monaco-editor.js +10 -2
- package/lib/browser/simple-monaco-editor.js.map +1 -1
- package/lib/browser/textmate/index.js +5 -14
- package/lib/browser/textmate/index.js.map +1 -1
- package/lib/browser/textmate/monaco-textmate-service.js +19 -27
- package/lib/browser/textmate/monaco-textmate-service.js.map +1 -1
- package/lib/browser/textmate/monaco-theme-registry.js +4 -12
- package/lib/browser/textmate/monaco-theme-registry.js.map +1 -1
- package/lib/browser/textmate/textmate-registry.js +2 -7
- package/lib/browser/textmate/textmate-registry.js.map +1 -1
- package/lib/browser/workspace-symbol-command.js +14 -22
- package/lib/browser/workspace-symbol-command.js.map +1 -1
- package/package.json +11 -10
- package/src/browser/markdown-renderer/monaco-markdown-renderer.ts +10 -18
- package/src/browser/monaco-bulk-edit-service.ts +2 -2
- package/src/browser/monaco-command-registry.ts +4 -1
- package/src/browser/monaco-command-service.ts +16 -25
- package/src/browser/monaco-command.ts +5 -15
- package/src/browser/monaco-context-key-service.ts +7 -6
- package/src/browser/monaco-context-menu.ts +13 -3
- package/src/browser/monaco-diff-editor.ts +8 -9
- package/src/browser/monaco-diff-navigator-factory.ts +6 -28
- package/src/browser/monaco-editor-model.ts +6 -3
- package/src/browser/monaco-editor-provider.ts +25 -59
- package/src/browser/monaco-editor-service.ts +10 -5
- package/src/browser/monaco-editor.ts +28 -9
- package/src/browser/monaco-frontend-application-contribution.ts +0 -35
- package/src/browser/monaco-frontend-module.ts +25 -17
- package/src/browser/monaco-icon-registry.ts +6 -4
- package/src/browser/monaco-init.ts +114 -0
- package/src/browser/monaco-keybinding.ts +3 -3
- package/src/browser/monaco-quick-input-service.ts +114 -96
- package/src/browser/monaco-resolved-keybinding.ts +23 -23
- package/src/browser/monaco-text-model-service.ts +1 -1
- package/src/browser/monaco-workspace.ts +10 -10
- package/src/browser/simple-monaco-editor.ts +9 -2
- package/src/browser/textmate/monaco-textmate-service.ts +1 -1
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 STMicroelectronics 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
|
+
/*
|
|
18
|
+
* The code in this file is responsible for overriding service implementations in the Monaco editor with our own Theia-based implementations.
|
|
19
|
+
* Since we only get a single chance to call `StandaloneServies.initialize()` with our overrides, we need to make sure that intialize is called before the first call to
|
|
20
|
+
* `StandaloneServices.get()` or `StandaloneServies.initialize()`. As we do not control the mechanics of Inversify instance constructions, the approach here is to call
|
|
21
|
+
* `MonacoInit.init()` from the `index.js` file after all container modules are loaded, but before the first object is fetched from it.
|
|
22
|
+
* `StandaloneServices.initialize()` is called with service descriptors, not service instances. This lets us finish all overrides before any inversify object is constructed and
|
|
23
|
+
* might call `initialize()` while being constructed.
|
|
24
|
+
* The service descriptors require a constructor function, so we declare dummy class for each Monaco service we override. But instead of returning an instance of the dummy class,
|
|
25
|
+
* we fetch the implementation of the monaco service from the inversify container.
|
|
26
|
+
* The inversify-constructed services must not call StandaloneServices.get() or StandaloneServices.initialize() from their constructors. Calling `get`()` in postConstruct mehtods
|
|
27
|
+
* is allowed.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
import { Container } from '@theia/core/shared/inversify';
|
|
31
|
+
import { ICodeEditorService } from '@theia/monaco-editor-core/esm/vs/editor/browser/services/codeEditorService';
|
|
32
|
+
import { StandaloneServices } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
|
|
33
|
+
import { SyncDescriptor } from '@theia/monaco-editor-core/esm/vs/platform/instantiation/common/descriptors';
|
|
34
|
+
import { MonacoEditorServiceFactory, MonacoEditorServiceFactoryType } from './monaco-editor-service';
|
|
35
|
+
import { IConfigurationService } from '@theia/monaco-editor-core/esm/vs/platform/configuration/common/configuration';
|
|
36
|
+
import { ITextModelService } from '@theia/monaco-editor-core/esm/vs/editor/common/services/resolverService';
|
|
37
|
+
import { MonacoConfigurationService } from './monaco-frontend-module';
|
|
38
|
+
import { MonacoTextModelService } from './monaco-text-model-service';
|
|
39
|
+
import { MonacoContextMenuService } from './monaco-context-menu';
|
|
40
|
+
import { IContextMenuService } from '@theia/monaco-editor-core/esm/vs/platform/contextview/browser/contextView';
|
|
41
|
+
import { IContextKeyService } from '@theia/monaco-editor-core/esm/vs/platform/contextkey/common/contextkey';
|
|
42
|
+
import { IThemeService } from '@theia/monaco-editor-core/esm/vs/platform/theme/common/themeService';
|
|
43
|
+
import { MonacoBulkEditService } from './monaco-bulk-edit-service';
|
|
44
|
+
import { MonacoCommandService } from './monaco-command-service';
|
|
45
|
+
import { IBulkEditService } from '@theia/monaco-editor-core/esm/vs/editor/browser/services/bulkEditService';
|
|
46
|
+
import { ICommandService } from '@theia/monaco-editor-core/esm/vs/platform/commands/common/commands';
|
|
47
|
+
import { MonacoQuickInputImplementation } from './monaco-quick-input-service';
|
|
48
|
+
import { IQuickInputService } from '@theia/monaco-editor-core/esm/vs/platform/quickinput/common/quickInput';
|
|
49
|
+
|
|
50
|
+
class MonacoEditorServiceConstructor {
|
|
51
|
+
/**
|
|
52
|
+
* MonacoEditorService needs other Monaco services as constructor parameters, so we need to do use a factory for constructing the service. If we want the singleton instance,
|
|
53
|
+
* we need to fetch it from the `StandaloneServices` class instead of injecting it.
|
|
54
|
+
* @param container
|
|
55
|
+
* @param contextKeyService
|
|
56
|
+
* @param themeService
|
|
57
|
+
*/
|
|
58
|
+
constructor(container: Container,
|
|
59
|
+
@IContextKeyService contextKeyService: IContextKeyService,
|
|
60
|
+
@IThemeService themeService: IThemeService) {
|
|
61
|
+
|
|
62
|
+
return container.get<MonacoEditorServiceFactoryType>(MonacoEditorServiceFactory)(contextKeyService, themeService);
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
class MonacoConfigurationServiceConstructor {
|
|
67
|
+
constructor(container: Container) {
|
|
68
|
+
return container.get(MonacoConfigurationService);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
class MonacoTextModelServiceConstructor {
|
|
73
|
+
constructor(container: Container) {
|
|
74
|
+
return container.get(MonacoTextModelService);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
class MonacoContextMenuServiceConstructor {
|
|
79
|
+
constructor(container: Container) {
|
|
80
|
+
return container.get(MonacoContextMenuService);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
class MonacoBulkEditServiceConstructor {
|
|
85
|
+
constructor(container: Container) {
|
|
86
|
+
return container.get(MonacoBulkEditService);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
class MonacoCommandServiceConstructor {
|
|
91
|
+
constructor(container: Container) {
|
|
92
|
+
return container.get(MonacoCommandService);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
class MonacoQuickInputImplementationConstructor {
|
|
97
|
+
constructor(container: Container) {
|
|
98
|
+
return container.get(MonacoQuickInputImplementation);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export namespace MonacoInit {
|
|
103
|
+
export function init(container: Container): void {
|
|
104
|
+
StandaloneServices.initialize({
|
|
105
|
+
[ICodeEditorService.toString()]: new SyncDescriptor(MonacoEditorServiceConstructor, [container]),
|
|
106
|
+
[IConfigurationService.toString()]: new SyncDescriptor(MonacoConfigurationServiceConstructor, [container]),
|
|
107
|
+
[ITextModelService.toString()]: new SyncDescriptor(MonacoTextModelServiceConstructor, [container]),
|
|
108
|
+
[IContextMenuService.toString()]: new SyncDescriptor(MonacoContextMenuServiceConstructor, [container]),
|
|
109
|
+
[IBulkEditService.toString()]: new SyncDescriptor(MonacoBulkEditServiceConstructor, [container]),
|
|
110
|
+
[ICommandService.toString()]: new SyncDescriptor(MonacoCommandServiceConstructor, [container]),
|
|
111
|
+
[IQuickInputService.toString()]: new SyncDescriptor(MonacoQuickInputImplementationConstructor, [container]),
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
@@ -45,14 +45,14 @@ export class MonacoKeybindingContribution implements KeybindingContribution {
|
|
|
45
45
|
registerKeybindings(registry: KeybindingRegistry): void {
|
|
46
46
|
const defaultKeybindings = KeybindingsRegistry.getDefaultKeybindings();
|
|
47
47
|
for (const item of defaultKeybindings) {
|
|
48
|
-
const command = this.commands.validate(item.command);
|
|
49
|
-
if (command) {
|
|
48
|
+
const command = this.commands.validate(item.command || undefined);
|
|
49
|
+
if (command && item.keybinding) {
|
|
50
50
|
const when = (item.when && item.when.serialize()) ?? undefined;
|
|
51
51
|
let keybinding;
|
|
52
52
|
if (item.command === MonacoCommands.GO_TO_DEFINITION && !environment.electron.is()) {
|
|
53
53
|
keybinding = 'ctrlcmd+f11';
|
|
54
54
|
} else {
|
|
55
|
-
keybinding = MonacoResolvedKeybinding.toKeybinding(item.keybinding);
|
|
55
|
+
keybinding = MonacoResolvedKeybinding.toKeybinding(item.keybinding.chords);
|
|
56
56
|
}
|
|
57
57
|
registry.registerKeybinding({ command, keybinding, when });
|
|
58
58
|
}
|
|
@@ -16,21 +16,21 @@
|
|
|
16
16
|
|
|
17
17
|
import {
|
|
18
18
|
ApplicationShell,
|
|
19
|
-
InputBox, InputOptions, KeybindingRegistry,
|
|
19
|
+
InputBox, InputOptions, KeybindingRegistry, PickOptions,
|
|
20
20
|
QuickInputButton, QuickInputHideReason, QuickInputService, QuickPick, QuickPickItem,
|
|
21
|
-
QuickPickItemButtonEvent, QuickPickItemHighlights, QuickPickOptions, QuickPickSeparator
|
|
21
|
+
QuickPickItemButtonEvent, QuickPickItemHighlights, QuickPickOptions, QuickPickSeparator
|
|
22
22
|
} from '@theia/core/lib/browser';
|
|
23
23
|
import { injectable, inject, postConstruct } from '@theia/core/shared/inversify';
|
|
24
24
|
import {
|
|
25
25
|
IInputBox, IInputOptions, IKeyMods, IPickOptions, IQuickInput, IQuickInputButton,
|
|
26
|
-
IQuickInputService, IQuickNavigateConfiguration, IQuickPick, IQuickPickItem, IQuickPickItemButtonEvent, IQuickPickSeparator, QuickPickInput
|
|
26
|
+
IQuickInputService, IQuickNavigateConfiguration, IQuickPick, IQuickPickItem, IQuickPickItemButtonEvent, IQuickPickSeparator, IQuickWidget, QuickPickInput
|
|
27
27
|
} from '@theia/monaco-editor-core/esm/vs/platform/quickinput/common/quickInput';
|
|
28
|
-
import { IQuickInputOptions, IQuickInputStyles
|
|
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';
|
|
29
30
|
import { MonacoResolvedKeybinding } from './monaco-resolved-keybinding';
|
|
30
31
|
import { IQuickAccessController } from '@theia/monaco-editor-core/esm/vs/platform/quickinput/common/quickAccess';
|
|
31
32
|
import { QuickAccessController } from '@theia/monaco-editor-core/esm/vs/platform/quickinput/browser/quickAccess';
|
|
32
|
-
import {
|
|
33
|
-
import { IContextKey } from '@theia/monaco-editor-core/esm/vs/platform/contextkey/common/contextkey';
|
|
33
|
+
import { IContextKey, IContextKeyService } from '@theia/monaco-editor-core/esm/vs/platform/contextkey/common/contextkey';
|
|
34
34
|
import { IListOptions, List } from '@theia/monaco-editor-core/esm/vs/base/browser/ui/list/listWidget';
|
|
35
35
|
import * as monaco from '@theia/monaco-editor-core';
|
|
36
36
|
import { ResolvedKeybinding } from '@theia/monaco-editor-core/esm/vs/base/common/keybindings';
|
|
@@ -38,11 +38,10 @@ import { IInstantiationService } from '@theia/monaco-editor-core/esm/vs/platform
|
|
|
38
38
|
import { StandaloneServices } from '@theia/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
|
|
39
39
|
import { IMatch } from '@theia/monaco-editor-core/esm/vs/base/common/filters';
|
|
40
40
|
import { IListRenderer, IListVirtualDelegate } from '@theia/monaco-editor-core/esm/vs/base/browser/ui/list/list';
|
|
41
|
-
import { Event } from '@theia/core';
|
|
41
|
+
import { CancellationToken, Event } from '@theia/core';
|
|
42
42
|
import { MonacoColorRegistry } from './monaco-color-registry';
|
|
43
43
|
import { ThemeService } from '@theia/core/lib/browser/theming';
|
|
44
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
45
|
|
|
47
46
|
// Copied from @vscode/src/vs/base/parts/quickInput/browser/quickInputList.ts
|
|
48
47
|
export interface IListElement {
|
|
@@ -62,6 +61,7 @@ export interface IListElement {
|
|
|
62
61
|
|
|
63
62
|
@injectable()
|
|
64
63
|
export class MonacoQuickInputImplementation implements IQuickInputService {
|
|
64
|
+
|
|
65
65
|
declare readonly _serviceBrand: undefined;
|
|
66
66
|
|
|
67
67
|
controller: QuickInputController;
|
|
@@ -76,9 +76,6 @@ export class MonacoQuickInputImplementation implements IQuickInputService {
|
|
|
76
76
|
@inject(ThemeService)
|
|
77
77
|
protected readonly themeService: ThemeService;
|
|
78
78
|
|
|
79
|
-
@inject(VSCodeContextKeyService)
|
|
80
|
-
protected readonly contextKeyService: VSCodeContextKeyService;
|
|
81
|
-
|
|
82
79
|
protected container: HTMLElement;
|
|
83
80
|
private quickInputList: List<unknown>;
|
|
84
81
|
|
|
@@ -93,25 +90,29 @@ export class MonacoQuickInputImplementation implements IQuickInputService {
|
|
|
93
90
|
this.initContainer();
|
|
94
91
|
this.initController();
|
|
95
92
|
this.quickAccess = new QuickAccessController(this, StandaloneServices.get(IInstantiationService));
|
|
96
|
-
this.inQuickOpen =
|
|
93
|
+
this.inQuickOpen = StandaloneServices.get(IContextKeyService).createKey<boolean>('inQuickOpen', false);
|
|
97
94
|
this.controller.onShow(() => {
|
|
98
95
|
this.container.style.top = this.shell.mainPanel.node.getBoundingClientRect().top + 'px';
|
|
99
96
|
this.inQuickOpen.set(true);
|
|
100
97
|
});
|
|
101
98
|
this.controller.onHide(() => this.inQuickOpen.set(false));
|
|
102
99
|
|
|
103
|
-
this.themeService.initialized.then(() => this.controller.applyStyles(this.
|
|
100
|
+
this.themeService.initialized.then(() => this.controller.applyStyles(this.computeStyles()));
|
|
104
101
|
// Hook into the theming service of Monaco to ensure that the updates are ready.
|
|
105
|
-
StandaloneServices.get(IStandaloneThemeService).onDidColorThemeChange(() => this.controller.applyStyles(this.
|
|
102
|
+
StandaloneServices.get(IStandaloneThemeService).onDidColorThemeChange(() => this.controller.applyStyles(this.computeStyles()));
|
|
106
103
|
window.addEventListener('resize', () => this.updateLayout());
|
|
107
104
|
}
|
|
108
105
|
|
|
109
106
|
setContextKey(key: string | undefined): void {
|
|
110
107
|
if (key) {
|
|
111
|
-
|
|
108
|
+
StandaloneServices.get(IContextKeyService).createKey<string>(key, undefined);
|
|
112
109
|
}
|
|
113
110
|
}
|
|
114
111
|
|
|
112
|
+
createQuickWidget(): IQuickWidget {
|
|
113
|
+
return this.controller.createQuickWidget();
|
|
114
|
+
}
|
|
115
|
+
|
|
115
116
|
createQuickPick<T extends IQuickPickItem>(): IQuickPick<T> {
|
|
116
117
|
return this.controller.createQuickPick<T>();
|
|
117
118
|
}
|
|
@@ -184,7 +185,7 @@ export class MonacoQuickInputImplementation implements IQuickInputService {
|
|
|
184
185
|
}
|
|
185
186
|
|
|
186
187
|
private initController(): void {
|
|
187
|
-
this.controller = new QuickInputController(this.getOptions());
|
|
188
|
+
this.controller = new QuickInputController(this.getOptions(), StandaloneServices.get(IStandaloneThemeService));
|
|
188
189
|
this.updateLayout();
|
|
189
190
|
}
|
|
190
191
|
|
|
@@ -202,72 +203,107 @@ export class MonacoQuickInputImplementation implements IQuickInputService {
|
|
|
202
203
|
const options: IQuickInputOptions = {
|
|
203
204
|
idPrefix: 'quickInput_',
|
|
204
205
|
container: this.container,
|
|
205
|
-
styles:
|
|
206
|
+
styles: this.computeStyles(),
|
|
206
207
|
ignoreFocusOut: () => false,
|
|
207
|
-
isScreenReaderOptimized: () => false, // TODO change to true once support is added.
|
|
208
208
|
backKeybindingLabel: () => undefined,
|
|
209
209
|
setContextKey: (id?: string) => this.setContextKey(id),
|
|
210
210
|
returnFocus: () => this.container.focus(),
|
|
211
211
|
createList: <T>(
|
|
212
212
|
user: string, container: HTMLElement, delegate: IListVirtualDelegate<T>, renderers: IListRenderer<T, unknown>[], listOptions: IListOptions<T>
|
|
213
213
|
): List<T> => this.quickInputList = new List(user, container, delegate, renderers, listOptions),
|
|
214
|
+
linkOpenerDelegate: () => {
|
|
215
|
+
// @monaco-uplift: not sure what to do here
|
|
216
|
+
}
|
|
214
217
|
};
|
|
215
218
|
return options;
|
|
216
219
|
}
|
|
217
220
|
|
|
218
221
|
// @monaco-uplift
|
|
219
222
|
// Keep the styles up to date with https://github.com/microsoft/vscode/blob/7888ff3a6b104e9e2e3d0f7890ca92dd0828215f/src/vs/platform/quickinput/browser/quickInput.ts#L171.
|
|
220
|
-
private
|
|
223
|
+
private computeStyles(): IQuickInputStyles {
|
|
221
224
|
return {
|
|
225
|
+
toggle: {
|
|
226
|
+
inputActiveOptionBorder: this.colorRegistry.toCssVariableName('inputOption.activeBorder'),
|
|
227
|
+
inputActiveOptionForeground: this.colorRegistry.toCssVariableName('inputOption.activeForeground'),
|
|
228
|
+
inputActiveOptionBackground: this.colorRegistry.toCssVariableName('inputOption.activeBackground')
|
|
229
|
+
},
|
|
230
|
+
pickerGroup: {
|
|
231
|
+
pickerGroupBorder: this.colorRegistry.toCssVariableName('pickerGroup.Border'),
|
|
232
|
+
pickerGroupForeground: this.colorRegistry.toCssVariableName('pickerGroupForeground')
|
|
233
|
+
},
|
|
222
234
|
widget: {
|
|
223
|
-
quickInputBackground: this.colorRegistry.
|
|
224
|
-
quickInputForeground: this.colorRegistry.
|
|
225
|
-
quickInputTitleBackground: this.colorRegistry.
|
|
235
|
+
quickInputBackground: this.colorRegistry.toCssVariableName('quickInput.background'),
|
|
236
|
+
quickInputForeground: this.colorRegistry.toCssVariableName('quickInput.foreground'),
|
|
237
|
+
quickInputTitleBackground: this.colorRegistry.toCssVariableName('quickInputTitle.background'),
|
|
238
|
+
widgetBorder: this.colorRegistry.toCssVariableName('widget.border'),
|
|
239
|
+
widgetShadow: this.colorRegistry.toCssVariableName('widget.shadow')
|
|
226
240
|
},
|
|
227
241
|
list: {
|
|
228
|
-
listBackground: this.colorRegistry.
|
|
229
|
-
listInactiveFocusForeground: this.colorRegistry.
|
|
230
|
-
listInactiveSelectionIconForeground: this.colorRegistry.
|
|
231
|
-
listInactiveFocusBackground: this.colorRegistry.
|
|
232
|
-
listFocusOutline: this.colorRegistry.
|
|
233
|
-
listInactiveFocusOutline: this.colorRegistry.
|
|
234
|
-
|
|
235
|
-
|
|
242
|
+
listBackground: this.colorRegistry.toCssVariableName('quickInput.background'),
|
|
243
|
+
listInactiveFocusForeground: this.colorRegistry.toCssVariableName('quickInputList.focusForeground'),
|
|
244
|
+
listInactiveSelectionIconForeground: this.colorRegistry.toCssVariableName('quickInputList.focusIconForeground'),
|
|
245
|
+
listInactiveFocusBackground: this.colorRegistry.toCssVariableName('quickInputList.focusBackground'),
|
|
246
|
+
listFocusOutline: this.colorRegistry.toCssVariableName('activeContrastBorder'),
|
|
247
|
+
listInactiveFocusOutline: this.colorRegistry.toCssVariableName('activeContrastBorder'),
|
|
248
|
+
|
|
249
|
+
listFocusBackground: this.colorRegistry.toCssVariableName('list.focusBackground'),
|
|
250
|
+
listFocusForeground: this.colorRegistry.toCssVariableName('list.focusForeground'),
|
|
251
|
+
listActiveSelectionBackground: this.colorRegistry.toCssVariableName('list.activeSelectionBackground'),
|
|
252
|
+
listActiveSelectionForeground: this.colorRegistry.toCssVariableName('list.ActiveSelectionForeground'),
|
|
253
|
+
listActiveSelectionIconForeground: this.colorRegistry.toCssVariableName('list.ActiveSelectionIconForeground'),
|
|
254
|
+
listFocusAndSelectionOutline: this.colorRegistry.toCssVariableName('list.FocusAndSelectionOutline'),
|
|
255
|
+
listFocusAndSelectionBackground: this.colorRegistry.toCssVariableName('list.ActiveSelectionBackground'),
|
|
256
|
+
listFocusAndSelectionForeground: this.colorRegistry.toCssVariableName('list.ActiveSelectionForeground'),
|
|
257
|
+
listInactiveSelectionBackground: this.colorRegistry.toCssVariableName('list.InactiveSelectionBackground'),
|
|
258
|
+
listInactiveSelectionForeground: this.colorRegistry.toCssVariableName('list.InactiveSelectionForeground'),
|
|
259
|
+
listHoverBackground: this.colorRegistry.toCssVariableName('list.HoverBackground'),
|
|
260
|
+
listHoverForeground: this.colorRegistry.toCssVariableName('list.HoverForeground'),
|
|
261
|
+
listDropBackground: this.colorRegistry.toCssVariableName('list.DropBackground'),
|
|
262
|
+
listSelectionOutline: this.colorRegistry.toCssVariableName('activeContrastBorder'),
|
|
263
|
+
listHoverOutline: this.colorRegistry.toCssVariableName('activeContrastBorder'),
|
|
264
|
+
treeIndentGuidesStroke: this.colorRegistry.toCssVariableName('tree.indentGuidesStroke'),
|
|
265
|
+
treeInactiveIndentGuidesStroke: this.colorRegistry.toCssVariableName('tree.inactiveIndentGuidesStroke'),
|
|
266
|
+
tableColumnsBorder: this.colorRegistry.toCssVariableName('tree.tableColumnsBorder'),
|
|
267
|
+
tableOddRowsBackgroundColor: this.colorRegistry.toCssVariableName('tree.tableOddRowsBackground'),
|
|
236
268
|
},
|
|
237
269
|
inputBox: {
|
|
238
|
-
inputForeground: this.colorRegistry.
|
|
239
|
-
inputBackground: this.colorRegistry.
|
|
240
|
-
inputBorder: this.colorRegistry.
|
|
241
|
-
inputValidationInfoBackground: this.colorRegistry.
|
|
242
|
-
inputValidationInfoForeground: this.colorRegistry.
|
|
243
|
-
inputValidationInfoBorder: this.colorRegistry.
|
|
244
|
-
inputValidationWarningBackground: this.colorRegistry.
|
|
245
|
-
inputValidationWarningForeground: this.colorRegistry.
|
|
246
|
-
inputValidationWarningBorder: this.colorRegistry.
|
|
247
|
-
inputValidationErrorBackground: this.colorRegistry.
|
|
248
|
-
inputValidationErrorForeground: this.colorRegistry.
|
|
249
|
-
inputValidationErrorBorder: this.colorRegistry.
|
|
270
|
+
inputForeground: this.colorRegistry.toCssVariableName('inputForeground'),
|
|
271
|
+
inputBackground: this.colorRegistry.toCssVariableName('inputBackground'),
|
|
272
|
+
inputBorder: this.colorRegistry.toCssVariableName('inputBorder'),
|
|
273
|
+
inputValidationInfoBackground: this.colorRegistry.toCssVariableName('inputValidation.infoBackground'),
|
|
274
|
+
inputValidationInfoForeground: this.colorRegistry.toCssVariableName('inputValidation.infoForeground'),
|
|
275
|
+
inputValidationInfoBorder: this.colorRegistry.toCssVariableName('inputValidation.infoBorder'),
|
|
276
|
+
inputValidationWarningBackground: this.colorRegistry.toCssVariableName('inputValidation.warningBackground'),
|
|
277
|
+
inputValidationWarningForeground: this.colorRegistry.toCssVariableName('inputValidation.warningForeground'),
|
|
278
|
+
inputValidationWarningBorder: this.colorRegistry.toCssVariableName('inputValidation.warningBorder'),
|
|
279
|
+
inputValidationErrorBackground: this.colorRegistry.toCssVariableName('inputValidation.errorBackground'),
|
|
280
|
+
inputValidationErrorForeground: this.colorRegistry.toCssVariableName('inputValidation.errorForeground'),
|
|
281
|
+
inputValidationErrorBorder: this.colorRegistry.toCssVariableName('inputValidation.errorBorder'),
|
|
250
282
|
},
|
|
251
283
|
countBadge: {
|
|
252
|
-
badgeBackground: this.colorRegistry.
|
|
253
|
-
badgeForeground: this.colorRegistry.
|
|
254
|
-
badgeBorder: this.colorRegistry.
|
|
284
|
+
badgeBackground: this.colorRegistry.toCssVariableName('badge.background'),
|
|
285
|
+
badgeForeground: this.colorRegistry.toCssVariableName('badge.foreground'),
|
|
286
|
+
badgeBorder: this.colorRegistry.toCssVariableName('contrastBorder')
|
|
255
287
|
},
|
|
256
288
|
button: {
|
|
257
|
-
buttonForeground: this.colorRegistry.
|
|
258
|
-
buttonBackground: this.colorRegistry.
|
|
259
|
-
buttonHoverBackground: this.colorRegistry.
|
|
260
|
-
buttonBorder: this.colorRegistry.
|
|
289
|
+
buttonForeground: this.colorRegistry.toCssVariableName('button.foreground'),
|
|
290
|
+
buttonBackground: this.colorRegistry.toCssVariableName('button.background'),
|
|
291
|
+
buttonHoverBackground: this.colorRegistry.toCssVariableName('button.hoverBackground'),
|
|
292
|
+
buttonBorder: this.colorRegistry.toCssVariableName('contrastBorder'),
|
|
293
|
+
buttonSeparator: this.colorRegistry.toCssVariableName('button.Separator'),
|
|
294
|
+
buttonSecondaryForeground: this.colorRegistry.toCssVariableName('button.secondaryForeground'),
|
|
295
|
+
buttonSecondaryBackground: this.colorRegistry.toCssVariableName('button.secondaryBackground'),
|
|
296
|
+
buttonSecondaryHoverBackground: this.colorRegistry.toCssVariableName('button.secondaryHoverBackground'),
|
|
261
297
|
},
|
|
262
298
|
progressBar: {
|
|
263
|
-
progressBarBackground: this.colorRegistry.
|
|
299
|
+
progressBarBackground: this.colorRegistry.toCssVariableName('progressBar.background')
|
|
264
300
|
},
|
|
265
301
|
keybindingLabel: {
|
|
266
|
-
keybindingLabelBackground: this.colorRegistry.
|
|
267
|
-
keybindingLabelForeground: this.colorRegistry.
|
|
268
|
-
keybindingLabelBorder: this.colorRegistry.
|
|
269
|
-
keybindingLabelBottomBorder: this.colorRegistry.
|
|
270
|
-
keybindingLabelShadow: this.colorRegistry.
|
|
302
|
+
keybindingLabelBackground: this.colorRegistry.toCssVariableName('keybindingLabel.background'),
|
|
303
|
+
keybindingLabelForeground: this.colorRegistry.toCssVariableName('keybindingLabel.foreground'),
|
|
304
|
+
keybindingLabelBorder: this.colorRegistry.toCssVariableName('keybindingLabel.border'),
|
|
305
|
+
keybindingLabelBottomBorder: this.colorRegistry.toCssVariableName('keybindingLabel.bottomBorder'),
|
|
306
|
+
keybindingLabelShadow: this.colorRegistry.toCssVariableName('widget.shadow')
|
|
271
307
|
},
|
|
272
308
|
};
|
|
273
309
|
}
|
|
@@ -282,7 +318,8 @@ export class MonacoQuickInputService implements QuickInputService {
|
|
|
282
318
|
protected readonly keybindingRegistry: KeybindingRegistry;
|
|
283
319
|
|
|
284
320
|
get backButton(): QuickInputButton {
|
|
285
|
-
|
|
321
|
+
// need to cast because of vscode issue https://github.com/microsoft/vscode/issues/190584
|
|
322
|
+
return this.monacoService.backButton as QuickInputButton;
|
|
286
323
|
}
|
|
287
324
|
|
|
288
325
|
get onShow(): Event<void> { return this.monacoService.onShow; }
|
|
@@ -293,7 +330,8 @@ export class MonacoQuickInputService implements QuickInputService {
|
|
|
293
330
|
}
|
|
294
331
|
|
|
295
332
|
createInputBox(): InputBox {
|
|
296
|
-
|
|
333
|
+
// need to cast because of vscode issue https://github.com/microsoft/vscode/issues/190584
|
|
334
|
+
return this.monacoService.createInputBox() as InputBox;
|
|
297
335
|
}
|
|
298
336
|
|
|
299
337
|
input(options?: InputOptions, token?: monaco.CancellationToken): Promise<string | undefined> {
|
|
@@ -309,39 +347,9 @@ export class MonacoQuickInputService implements QuickInputService {
|
|
|
309
347
|
}
|
|
310
348
|
|
|
311
349
|
async pick<T extends QuickPickItem, O extends PickOptions<T> = PickOptions<T>>(
|
|
312
|
-
picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: O, token?:
|
|
313
|
-
): Promise<
|
|
314
|
-
|
|
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;
|
|
350
|
+
picks: Promise<QuickPickInput<T>[]> | QuickPickInput<T>[], options?: O, token?: CancellationToken
|
|
351
|
+
): Promise<T[] | T | undefined> {
|
|
352
|
+
return this.monacoService.pick(picks, options, token);
|
|
345
353
|
}
|
|
346
354
|
|
|
347
355
|
showQuickPick<T extends QuickPickItem>(items: Array<T | QuickPickSeparator>, options?: QuickPickOptions<T>): Promise<T | undefined> {
|
|
@@ -394,7 +402,8 @@ export class MonacoQuickInputService implements QuickInputService {
|
|
|
394
402
|
});
|
|
395
403
|
wrapped.onDidTriggerButton((button: IQuickInputButton) => {
|
|
396
404
|
if (options.onDidTriggerButton) {
|
|
397
|
-
|
|
405
|
+
// need to cast because of vscode issue https://github.com/microsoft/vscode/issues/190584
|
|
406
|
+
options.onDidTriggerButton(button as QuickInputButton);
|
|
398
407
|
}
|
|
399
408
|
});
|
|
400
409
|
wrapped.onDidTriggerItemButton((event: QuickPickItemButtonEvent<T>) => {
|
|
@@ -577,7 +586,14 @@ class MonacoQuickPick<T extends QuickPickItem> extends MonacoQuickInput implemen
|
|
|
577
586
|
}
|
|
578
587
|
|
|
579
588
|
get items(): readonly (T | QuickPickSeparator)[] {
|
|
580
|
-
|
|
589
|
+
// need to cast because of vscode issue https://github.com/microsoft/vscode/issues/190584
|
|
590
|
+
return this.wrapped.items.map(item => {
|
|
591
|
+
if (item instanceof MonacoQuickPickItem) {
|
|
592
|
+
return item.item;
|
|
593
|
+
} else {
|
|
594
|
+
return item;
|
|
595
|
+
}
|
|
596
|
+
});
|
|
581
597
|
}
|
|
582
598
|
|
|
583
599
|
set items(itemList: readonly (T | QuickPickSeparator)[]) {
|
|
@@ -610,12 +626,14 @@ class MonacoQuickPick<T extends QuickPickItem> extends MonacoQuickInput implemen
|
|
|
610
626
|
|
|
611
627
|
readonly onDidAccept: Event<{ inBackground: boolean }> = this.wrapped.onDidAccept;
|
|
612
628
|
readonly onDidChangeValue: Event<string> = this.wrapped.onDidChangeValue;
|
|
613
|
-
|
|
629
|
+
|
|
630
|
+
// need to cast because of vscode issue https://github.com/microsoft/vscode/issues/190584
|
|
631
|
+
readonly onDidTriggerButton: Event<QuickInputButton> = this.wrapped.onDidTriggerButton as Event<QuickInputButton>;
|
|
614
632
|
readonly onDidTriggerItemButton: Event<QuickPickItemButtonEvent<T>> =
|
|
615
633
|
Event.map(this.wrapped.onDidTriggerItemButton, (evt: IQuickPickItemButtonEvent<MonacoQuickPickItem<T>>) => ({
|
|
616
634
|
item: evt.item.item,
|
|
617
635
|
button: evt.button
|
|
618
|
-
}))
|
|
636
|
+
})) as Event<QuickPickItemButtonEvent<T>>;
|
|
619
637
|
readonly onDidChangeActive: Event<T[]> = Event.map(
|
|
620
638
|
this.wrapped.onDidChangeActive,
|
|
621
639
|
(items: MonacoQuickPickItem<T>[]) => items.map(item => item.item));
|
|
@@ -630,7 +648,7 @@ class MonacoQuickPick<T extends QuickPickItem> extends MonacoQuickInput implemen
|
|
|
630
648
|
const monacoReferences: MonacoQuickPickItem<T>[] = [];
|
|
631
649
|
for (const item of items) {
|
|
632
650
|
for (const wrappedItem of source) {
|
|
633
|
-
if (
|
|
651
|
+
if (wrappedItem instanceof MonacoQuickPickItem && wrappedItem.item === item) {
|
|
634
652
|
monacoReferences.push(wrappedItem);
|
|
635
653
|
}
|
|
636
654
|
}
|
|
@@ -663,7 +681,7 @@ export class MonacoQuickPickItem<T extends QuickPickItem> implements IQuickPickI
|
|
|
663
681
|
this.detail = item.detail;
|
|
664
682
|
this.keybinding = item.keySequence ? new MonacoResolvedKeybinding(item.keySequence, kbRegistry) : undefined;
|
|
665
683
|
this.iconClasses = item.iconClasses;
|
|
666
|
-
this.buttons = item.buttons
|
|
684
|
+
this.buttons = item.buttons;
|
|
667
685
|
this.alwaysShow = item.alwaysShow;
|
|
668
686
|
this.highlights = item.highlights;
|
|
669
687
|
}
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { KeyCode as MonacoKeyCode } from '@theia/monaco-editor-core/esm/vs/base/common/keyCodes';
|
|
18
18
|
import {
|
|
19
|
-
|
|
19
|
+
ResolvedKeybinding, ResolvedChord, SingleModifierChord, KeyCodeChord, Chord
|
|
20
20
|
} from '@theia/monaco-editor-core/esm/vs/base/common/keybindings';
|
|
21
21
|
import { ElectronAcceleratorLabelProvider, UILabelProvider, UserSettingsLabelProvider } from '@theia/monaco-editor-core/esm/vs/base/common/keybindingLabels';
|
|
22
22
|
import { USLayoutResolvedKeybinding } from '@theia/monaco-editor-core/esm/vs/platform/keybinding/common/usLayoutResolvedKeybinding';
|
|
@@ -28,15 +28,15 @@ import { KEY_CODE_MAP } from './monaco-keycode-map';
|
|
|
28
28
|
|
|
29
29
|
export class MonacoResolvedKeybinding extends ResolvedKeybinding {
|
|
30
30
|
|
|
31
|
-
protected readonly
|
|
31
|
+
protected readonly chords: ResolvedChord[];
|
|
32
32
|
|
|
33
33
|
constructor(protected readonly keySequence: KeySequence, keybindingService: KeybindingRegistry) {
|
|
34
34
|
super();
|
|
35
|
-
this.
|
|
35
|
+
this.chords = keySequence.map(keyCode => {
|
|
36
36
|
// eslint-disable-next-line no-null/no-null
|
|
37
37
|
const keyLabel = keyCode.key ? keybindingService.acceleratorForKey(keyCode.key) : null;
|
|
38
38
|
const keyAriaLabel = keyLabel;
|
|
39
|
-
return new
|
|
39
|
+
return new ResolvedChord(
|
|
40
40
|
keyCode.ctrl,
|
|
41
41
|
keyCode.shift,
|
|
42
42
|
keyCode.alt,
|
|
@@ -48,43 +48,43 @@ export class MonacoResolvedKeybinding extends ResolvedKeybinding {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
getLabel(): string | null {
|
|
51
|
-
return UILabelProvider.toLabel(MonacoPlatform.OS, this.
|
|
51
|
+
return UILabelProvider.toLabel(MonacoPlatform.OS, this.chords, p => p.keyLabel);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
getAriaLabel(): string | null {
|
|
55
|
-
return UILabelProvider.toLabel(MonacoPlatform.OS, this.
|
|
55
|
+
return UILabelProvider.toLabel(MonacoPlatform.OS, this.chords, p => p.keyAriaLabel);
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
getElectronAccelerator(): string | null {
|
|
59
|
-
if (this.
|
|
59
|
+
if (this.hasMultipleChords()) {
|
|
60
60
|
// Electron cannot handle chords
|
|
61
61
|
// eslint-disable-next-line no-null/no-null
|
|
62
62
|
return null;
|
|
63
63
|
}
|
|
64
|
-
return ElectronAcceleratorLabelProvider.toLabel(MonacoPlatform.OS, this.
|
|
64
|
+
return ElectronAcceleratorLabelProvider.toLabel(MonacoPlatform.OS, this.chords, p => p.keyLabel);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
getUserSettingsLabel(): string | null {
|
|
68
|
-
return UserSettingsLabelProvider.toLabel(MonacoPlatform.OS, this.
|
|
68
|
+
return UserSettingsLabelProvider.toLabel(MonacoPlatform.OS, this.chords, p => p.keyLabel);
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
isWYSIWYG(): boolean {
|
|
72
72
|
return true;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
return this.
|
|
75
|
+
hasMultipleChords(): boolean {
|
|
76
|
+
return this.chords.length > 1;
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
getDispatchChords(): (string | null)[] {
|
|
80
80
|
return this.keySequence.map(keyCode => USLayoutResolvedKeybinding.getDispatchStr(this.toKeybinding(keyCode)));
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
getSingleModifierDispatchChords(): (SingleModifierChord | null)[] {
|
|
84
84
|
return this.keySequence.map(keybinding => this.getSingleModifierDispatchPart(keybinding));
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
protected getSingleModifierDispatchPart(code: KeyCode):
|
|
87
|
+
protected getSingleModifierDispatchPart(code: KeyCode): SingleModifierChord | null {
|
|
88
88
|
if (code.key?.keyCode === undefined) {
|
|
89
89
|
return null; // eslint-disable-line no-null/no-null
|
|
90
90
|
}
|
|
@@ -103,8 +103,8 @@ export class MonacoResolvedKeybinding extends ResolvedKeybinding {
|
|
|
103
103
|
return null; // eslint-disable-line no-null/no-null
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
private toKeybinding(keyCode: KeyCode):
|
|
107
|
-
return new
|
|
106
|
+
private toKeybinding(keyCode: KeyCode): KeyCodeChord {
|
|
107
|
+
return new KeyCodeChord(
|
|
108
108
|
keyCode.ctrl,
|
|
109
109
|
keyCode.shift,
|
|
110
110
|
keyCode.alt,
|
|
@@ -113,16 +113,16 @@ export class MonacoResolvedKeybinding extends ResolvedKeybinding {
|
|
|
113
113
|
);
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
public
|
|
117
|
-
return this.
|
|
116
|
+
public getChords(): ResolvedChord[] {
|
|
117
|
+
return this.chords;
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
-
static toKeybinding(keybindings: Array<
|
|
120
|
+
static toKeybinding(keybindings: Array<Chord>): string {
|
|
121
121
|
return keybindings.map(binding => this.keyCode(binding)).join(' ');
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
static keyCode(keybinding:
|
|
125
|
-
const keyCode = keybinding instanceof
|
|
124
|
+
static keyCode(keybinding: Chord): KeyCode {
|
|
125
|
+
const keyCode = keybinding instanceof KeyCodeChord ? keybinding.keyCode : USLayoutResolvedKeybinding['_scanCodeToKeyCode'](keybinding.scanCode);
|
|
126
126
|
const sequence: Keystroke = {
|
|
127
127
|
first: Key.getKey(this.monaco2BrowserKeyCode(keyCode & 0xff)),
|
|
128
128
|
modifiers: []
|
|
@@ -146,8 +146,8 @@ export class MonacoResolvedKeybinding extends ResolvedKeybinding {
|
|
|
146
146
|
return KeyCode.createKeyCode(sequence);
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
static keySequence(keybinding:
|
|
150
|
-
return keybinding.
|
|
149
|
+
static keySequence(keybinding: Chord[]): KeySequence {
|
|
150
|
+
return keybinding.map(part => this.keyCode(part));
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
private static monaco2BrowserKeyCode(keyCode: MonacoKeyCode): number {
|
|
@@ -194,6 +194,6 @@ export class MonacoTextModelService implements ITextModelService {
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
canHandleResource(resource: monaco.Uri): boolean {
|
|
197
|
-
return this.fileService.canHandleResource(
|
|
197
|
+
return this.fileService.canHandleResource(URI.fromComponents(resource));
|
|
198
198
|
}
|
|
199
199
|
}
|