mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-11-12 11:49:27 +00:00
patched the keybinding registry
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
28
arduino-ide-extension/src/browser/theia/core/keybindings.ts
Normal file
28
arduino-ide-extension/src/browser/theia/core/keybindings.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { injectable } from 'inversify';
|
||||
import { Command } from '@theia/core/lib/common/command';
|
||||
import { Keybinding } from '@theia/core/lib/common/keybinding';
|
||||
import { KeybindingRegistry as TheiaKeybindingRegistry, KeybindingScope } from '@theia/core/lib/browser/keybinding';
|
||||
|
||||
@injectable()
|
||||
export class KeybindingRegistry extends TheiaKeybindingRegistry {
|
||||
|
||||
// https://github.com/eclipse-theia/theia/issues/8209
|
||||
unregisterKeybinding(key: string): void;
|
||||
unregisterKeybinding(keybinding: Keybinding): void;
|
||||
unregisterKeybinding(command: Command): void;
|
||||
unregisterKeybinding(arg: string | Keybinding | Command): void {
|
||||
const keymap = this.keymaps[KeybindingScope.DEFAULT];
|
||||
const filter = Command.is(arg)
|
||||
? ({ command }: Keybinding) => command === arg.id
|
||||
: ({ keybinding }: Keybinding) => Keybinding.is(arg)
|
||||
? keybinding === arg.keybinding
|
||||
: keybinding === arg;
|
||||
for (const binding of keymap.filter(filter)) {
|
||||
const idx = keymap.indexOf(binding);
|
||||
if (idx !== -1) {
|
||||
keymap.splice(idx, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
import { injectable, inject } from 'inversify';
|
||||
import { WorkspaceCommands } from '@theia/workspace/lib/browser/workspace-commands';
|
||||
import { KeybindingRegistry } from '@theia/core/lib/browser/keybinding';
|
||||
import { FrontendApplication } from '@theia/core/lib/browser/frontend-application';
|
||||
import { FileNavigatorContribution as TheiaFileNavigatorContribution } from '@theia/navigator/lib/browser/navigator-contribution';
|
||||
import { EditorMode } from '../../editor-mode';
|
||||
@@ -15,4 +17,12 @@ export class FileNavigatorContribution extends TheiaFileNavigatorContribution {
|
||||
}
|
||||
}
|
||||
|
||||
registerKeybindings(registry: KeybindingRegistry): void {
|
||||
super.registerKeybindings(registry);
|
||||
[
|
||||
WorkspaceCommands.FILE_RENAME,
|
||||
WorkspaceCommands.FILE_DELETE
|
||||
].forEach(registry.unregisterKeybinding.bind(registry));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user