Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for Vscode emacs extension #6625

Merged
merged 1 commit into from
Dec 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions packages/core/src/browser/keybinding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import * as common from '../common/keybinding';

export enum KeybindingScope {
DEFAULT,
DEFAULT_OVERRIDING,
USER,
WORKSPACE,
END
Expand Down Expand Up @@ -191,9 +192,10 @@ export class KeybindingRegistry {
* Register a default keybinding to the registry.
*
* @param binding
* @param override Override existed keybinding
*/
registerKeybinding(binding: Keybinding): Disposable {
return this.doRegisterKeybinding(binding, KeybindingScope.DEFAULT);
registerKeybinding(binding: Keybinding, override?: boolean): Disposable {
return this.doRegisterKeybinding(binding, !!override ? KeybindingScope.DEFAULT_OVERRIDING : undefined);
}

/**
Expand Down Expand Up @@ -241,7 +243,7 @@ export class KeybindingRegistry {
protected doRegisterKeybinding(binding: Keybinding, scope: KeybindingScope = KeybindingScope.DEFAULT): Disposable {
try {
this.resolveKeybinding(binding);
if (this.containsKeybinding(this.keymaps[scope], binding)) {
if (this.containsKeybinding(this.keymaps[scope], binding) && scope !== KeybindingScope.DEFAULT_OVERRIDING) {
throw new Error(`"${binding.keybinding}" is in collision with something else [scope:${scope}]`);
}
this.keymaps[scope].push(binding);
Expand Down Expand Up @@ -452,6 +454,10 @@ export class KeybindingRegistry {
matches.partial = matches.partial.filter(
binding => this.getKeybindingCollisions(result.partial, binding).partial.length === 0);

if (scope === KeybindingScope.DEFAULT_OVERRIDING) {
matches.full.reverse();
matches.partial.reverse();
}
result.merge(matches);
}
this.sortKeybindingsByPriority(result.full);
Expand Down Expand Up @@ -622,7 +628,7 @@ export class KeybindingRegistry {
this.keySequence.push(keyCode);
const bindings = this.getKeybindingsForKeySequence(this.keySequence);

if (this.tryKeybindingExecution(bindings.full, event)) {
if (bindings.partial.length === 0 && this.tryKeybindingExecution(bindings.full, event)) {
akosyakov marked this conversation as resolved.
Show resolved Hide resolved

this.keySequence = [];
this.statusBar.removeElement('keybinding-status');
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/browser/keyboard/keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export class KeyCode {
}

const schema: KeyCodeSchema = {};
const keys = keybinding.trim().toLowerCase().split('+');
const keys = keybinding.trim().toLowerCase().split(/[-+]/g);
/* If duplicates i.e ctrl+ctrl+a or alt+alt+b or b+alt+b it is invalid */
if (keys.length !== new Set(keys).size) {
throw new Error(`Can't parse keybinding ${keybinding} Duplicate modifiers`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@
********************************************************************************/

import { Command, CommandContribution, CommandRegistry, ResourceProvider } from '@theia/core';
import { ApplicationShell, NavigatableWidget, open, OpenerService, Saveable } from '@theia/core/lib/browser';
import {
ApplicationShell,
CommonCommands,
NavigatableWidget,
open,
OpenerService,
PrefixQuickOpenService,
Saveable
} from '@theia/core/lib/browser';
import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
import { ApplicationShellMouseTracker } from '@theia/core/lib/browser/shell/application-shell-mouse-tracker';
import { CommandService } from '@theia/core/lib/common/command';
Expand Down Expand Up @@ -64,6 +72,8 @@ export class PluginVscodeCommandsContribution implements CommandContribution {
protected readonly openerService: OpenerService;
@inject(ApplicationShellMouseTracker)
protected readonly mouseTracker: ApplicationShellMouseTracker;
@inject(PrefixQuickOpenService)
protected readonly quickOpen: PrefixQuickOpenService;

registerCommands(commands: CommandRegistry): void {
commands.registerCommand(VscodeCommands.OPEN, {
Expand Down Expand Up @@ -138,6 +148,21 @@ export class PluginVscodeCommandsContribution implements CommandContribution {
commands.registerCommand({ id: 'workbench.action.files.openFolder' }, {
execute: () => commands.executeCommand(WorkspaceCommands.OPEN_FOLDER.id)
});
commands.registerCommand({ id: 'workbench.action.gotoLine' }, {
execute: () => commands.executeCommand('editor.action.gotoLine')
});
commands.registerCommand({ id: 'actions.find' }, {
execute: () => commands.executeCommand(CommonCommands.FIND.id)
});
commands.registerCommand({ id: 'undo' }, {
execute: () => commands.executeCommand(CommonCommands.UNDO.id)
});
commands.registerCommand({ id: 'editor.action.startFindReplaceAction' }, {
execute: () => commands.executeCommand(CommonCommands.REPLACE.id)
});
commands.registerCommand({ id: 'workbench.action.quickOpen' }, {
execute: () => this.quickOpen.open('')
});
commands.registerCommand({ id: 'default:type' }, {
execute: args => {
const editor = MonacoEditor.getCurrent(this.editorManager);
Expand Down
2 changes: 2 additions & 0 deletions packages/plugin-ext/src/common/known-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,10 @@ export namespace KnownCommands {
mappings['scrollPageUp'] = ['scrollPageUp', MONACO_CONVERSION_IDENTITY];
mappings['tab'] = ['tab', MONACO_CONVERSION_IDENTITY];
mappings['removeSecondaryCursors'] = ['removeSecondaryCursors', MONACO_CONVERSION_IDENTITY];
mappings['cursorWordRight'] = ['cursorWordEndRight', MONACO_CONVERSION_IDENTITY];
mappings['cursorWordEndRight'] = ['cursorWordEndRight', MONACO_CONVERSION_IDENTITY];
mappings['cursorWordEndRightSelect'] = ['cursorWordEndRightSelect', MONACO_CONVERSION_IDENTITY];
mappings['cursorWordLeft'] = ['cursorWordStartLeft', MONACO_CONVERSION_IDENTITY];
mappings['cursorWordStartLeft'] = ['cursorWordStartLeft', MONACO_CONVERSION_IDENTITY];
mappings['cursorWordStartLeftSelect'] = ['cursorWordStartLeftSelect', MONACO_CONVERSION_IDENTITY];
mappings['deleteWordLeft'] = ['deleteWordLeft', MONACO_CONVERSION_IDENTITY];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class KeybindingsContributionPointHandler {
for (const raw of contributions.keybindings) {
const keybinding = this.toKeybinding(raw);
if (keybinding) {
toDispose.push(this.keybindingRegistry.registerKeybinding(keybinding));
toDispose.push(this.keybindingRegistry.registerKeybinding(keybinding, true));
}
}
return toDispose;
Expand Down