-
-
Notifications
You must be signed in to change notification settings - Fork 435
/
Copy pathworkspace-frontend-contribution.ts
50 lines (46 loc) · 1.81 KB
/
workspace-frontend-contribution.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import { injectable } from '@theia/core/shared/inversify';
import { CommandRegistry } from '@theia/core/lib/common/command';
import { MenuModelRegistry } from '@theia/core/lib/common/menu';
import { KeybindingRegistry } from '@theia/core/lib/browser/keybinding';
import {
WorkspaceCommands,
FileMenuContribution,
} from '@theia/workspace/lib/browser/workspace-commands';
import { WorkspaceFrontendContribution as TheiaWorkspaceFrontendContribution } from '@theia/workspace/lib/browser/workspace-frontend-contribution';
@injectable()
export class WorkspaceFrontendContribution extends TheiaWorkspaceFrontendContribution {
override registerCommands(registry: CommandRegistry): void {
super.registerCommands(registry);
// TODO: instead of blacklisting commands to remove, it would be more robust to whitelist the ones we want to keep
const commands = new Set(registry.commands);
[
WorkspaceCommands.OPEN,
WorkspaceCommands.OPEN_FILE,
WorkspaceCommands.OPEN_FOLDER,
WorkspaceCommands.OPEN_WORKSPACE,
WorkspaceCommands.OPEN_RECENT_WORKSPACE,
WorkspaceCommands.SAVE_WORKSPACE_AS,
WorkspaceCommands.SAVE_AS,
WorkspaceCommands.CLOSE,
]
.filter(commands.has.bind(commands))
.forEach(registry.unregisterCommand.bind(registry));
}
override registerMenus(_: MenuModelRegistry): void {}
override registerKeybindings(registry: KeybindingRegistry): void {
super.registerKeybindings(registry);
[
WorkspaceCommands.NEW_FILE,
WorkspaceCommands.FILE_RENAME,
WorkspaceCommands.FILE_DELETE,
]
.map(({ id }) => id)
.forEach(registry.unregisterKeybinding.bind(registry));
}
}
@injectable()
export class ArduinoFileMenuContribution extends FileMenuContribution {
override registerMenus(_: MenuModelRegistry): void {
// NOOP
}
}