Skip to content

Commit 445ffed

Browse files
author
Akos Kitta
committed
patched the keybinding registry
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
1 parent bbf880d commit 445ffed

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

arduino-ide-extension/src/browser/arduino-ide-frontend-module.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ import {
3939
ApplicationShell as TheiaApplicationShell,
4040
ShellLayoutRestorer as TheiaShellLayoutRestorer,
4141
KeybindingContribution,
42-
CommonFrontendContribution as TheiaCommonFrontendContribution
42+
CommonFrontendContribution as TheiaCommonFrontendContribution,
43+
KeybindingRegistry as TheiaKeybindingRegistry
4344
} from '@theia/core/lib/browser';
4445
import { MenuContribution } from '@theia/core/lib/common/menu';
4546
import { ApplicationShell } from './theia/core/application-shell';
@@ -103,6 +104,7 @@ import { PreferencesContribution } from './theia/preferences/preference-contribu
103104
import { QuitApp } from './contributions/quit-app';
104105
import { SketchControl } from './contributions/sketch-control-contributions';
105106
import { Settings } from './contributions/settings';
107+
import { KeybindingRegistry } from './theia/core/keybindings';
106108

107109
const ElementQueries = require('css-element-queries/src/ElementQueries');
108110

@@ -278,6 +280,7 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
278280
rebind(TheiaFileMenuContribution).to(ArduinoFileMenuContribution).inSingletonScope();
279281
rebind(TheiaCommonFrontendContribution).to(CommonFrontendContribution).inSingletonScope();
280282
rebind(TheiaPreferencesContribution).to(PreferencesContribution).inSingletonScope();
283+
rebind(TheiaKeybindingRegistry).to(KeybindingRegistry).inSingletonScope();
281284

282285
// Show a disconnected status bar, when the daemon is not available
283286
bind(ApplicationConnectionStatusContribution).toSelf().inSingletonScope();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { injectable } from 'inversify';
2+
import { Command } from '@theia/core/lib/common/command';
3+
import { Keybinding } from '@theia/core/lib/common/keybinding';
4+
import { KeybindingRegistry as TheiaKeybindingRegistry, KeybindingScope } from '@theia/core/lib/browser/keybinding';
5+
6+
@injectable()
7+
export class KeybindingRegistry extends TheiaKeybindingRegistry {
8+
9+
// https://github.com/eclipse-theia/theia/issues/8209
10+
unregisterKeybinding(key: string): void;
11+
unregisterKeybinding(keybinding: Keybinding): void;
12+
unregisterKeybinding(command: Command): void;
13+
unregisterKeybinding(arg: string | Keybinding | Command): void {
14+
const keymap = this.keymaps[KeybindingScope.DEFAULT];
15+
const filter = Command.is(arg)
16+
? ({ command }: Keybinding) => command === arg.id
17+
: ({ keybinding }: Keybinding) => Keybinding.is(arg)
18+
? keybinding === arg.keybinding
19+
: keybinding === arg;
20+
for (const binding of keymap.filter(filter)) {
21+
const idx = keymap.indexOf(binding);
22+
if (idx !== -1) {
23+
keymap.splice(idx, 1);
24+
}
25+
}
26+
}
27+
28+
}

arduino-ide-extension/src/browser/theia/navigator/navigator-contribution.ts

+10
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { injectable, inject } from 'inversify';
2+
import { WorkspaceCommands } from '@theia/workspace/lib/browser/workspace-commands';
3+
import { KeybindingRegistry } from '@theia/core/lib/browser/keybinding';
24
import { FrontendApplication } from '@theia/core/lib/browser/frontend-application';
35
import { FileNavigatorContribution as TheiaFileNavigatorContribution } from '@theia/navigator/lib/browser/navigator-contribution';
46
import { EditorMode } from '../../editor-mode';
@@ -15,4 +17,12 @@ export class FileNavigatorContribution extends TheiaFileNavigatorContribution {
1517
}
1618
}
1719

20+
registerKeybindings(registry: KeybindingRegistry): void {
21+
super.registerKeybindings(registry);
22+
[
23+
WorkspaceCommands.FILE_RENAME,
24+
WorkspaceCommands.FILE_DELETE
25+
].forEach(registry.unregisterKeybinding.bind(registry));
26+
}
27+
1828
}

0 commit comments

Comments
 (0)