Skip to content

Commit

Permalink
Some fixes to editors key bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
KR155E committed Sep 7, 2024
1 parent 7fe3966 commit 529ebc4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,37 +52,37 @@ export const EDITORS_COMMANDS = {
paletteSelectIndex1: {
id: 'editors.fontEditor.paletteSelectIndex1',
label: nls.localize('vuengine/editors/commands/fontEditor/paletteSelectIndex1', 'Select Palette Index 1'),
keybinding: '1',
keybinding: 'shift+1',
},
paletteSelectIndex2: {
id: 'editors.fontEditor.paletteSelectIndex2',
label: nls.localize('vuengine/editors/commands/fontEditor/paletteSelectIndex2', 'Select Palette Index 2'),
keybinding: '2',
keybinding: 'shift+2',
},
paletteSelectIndex3: {
id: 'editors.fontEditor.paletteSelectIndex3',
label: nls.localize('vuengine/editors/commands/fontEditor/paletteSelectIndex3', 'Select Palette Index 3'),
keybinding: '3',
keybinding: 'shift+3',
},
paletteSelectIndex4: {
id: 'editors.fontEditor.paletteSelectIndex4',
label: nls.localize('vuengine/editors/commands/fontEditor/paletteSelectIndex4', 'Select Palette Index 4'),
keybinding: '4',
keybinding: 'shift+4',
},
paletteSelectIndex5: {
id: 'editors.fontEditor.paletteSelectIndex5',
label: nls.localize('vuengine/editors/commands/fontEditor/paletteSelectIndex5', 'Select Palette Index 5'),
keybinding: '5',
keybinding: 'shift+5',
},
paletteSelectIndex6: {
id: 'editors.fontEditor.paletteSelectIndex6',
label: nls.localize('vuengine/editors/commands/fontEditor/paletteSelectIndex6', 'Select Palette Index 6'),
keybinding: '6',
keybinding: 'shift+6',
},
paletteSelectIndex7: {
id: 'editors.fontEditor.paletteSelectIndex7',
label: nls.localize('vuengine/editors/commands/fontEditor/paletteSelectIndex7', 'Select Palette Index 7'),
keybinding: '7',
keybinding: 'shift+7',
},
swapColors: {
id: 'editors.fontEditor.swapColors',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Command, CommandContribution, CommandRegistry, CommandService, MenuContribution, MenuModelRegistry, URI, UntitledResourceResolver } from '@theia/core';
import { AbstractViewContribution, CommonCommands, KeybindingContribution, KeybindingRegistry, OpenerService, Widget, open } from '@theia/core/lib/browser';
import { AbstractViewContribution, CommonCommands, CommonMenus, KeybindingContribution, KeybindingRegistry, OpenerService, Widget, open } from '@theia/core/lib/browser';
import { FrontendApplicationState, FrontendApplicationStateService } from '@theia/core/lib/browser/frontend-application-state';
import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar';
import { UserWorkingDirectoryProvider } from '@theia/core/lib/browser/user-working-directory-provider';
Expand Down Expand Up @@ -130,7 +130,7 @@ export class VesEditorsViewContribution extends AbstractViewContribution<VesEdit
commandRegistry.registerCommand(Command.toLocalizedCommand(
{
id: `editors.new-untitled.${typeId}`,
label: `New Untitled ${type.schema.title || typeId} File`,
label: `New ${type.schema.title || typeId} File`,
category: CommonCommands.FILE_CATEGORY,
iconClass: type.icon,
},
Expand All @@ -145,7 +145,6 @@ export class VesEditorsViewContribution extends AbstractViewContribution<VesEdit
});
}

// TODO: hide from command palette
if (type.forFiles?.length) {
commandRegistry.registerCommand(Command.toLocalizedCommand(
{
Expand All @@ -155,6 +154,8 @@ export class VesEditorsViewContribution extends AbstractViewContribution<VesEdit
},
`vuengine/editors/newFile/${typeId}`
), {
// hide "new xyz conversion file" commands from command palette
isVisible: widget => this.shell.currentWidget?.id === 'files',
execute: async () => this.commandService.executeCommand(WorkspaceCommands.NEW_FILE.id),
});
}
Expand Down Expand Up @@ -189,7 +190,8 @@ export class VesEditorsViewContribution extends AbstractViewContribution<VesEdit
label: command.label,
category: editor.category,
}, {
isEnabled: () => true,
// enable and make visible only for the current type's editor
isEnabled: () => (this.shell.currentWidget as VesEditorsWidget)?.typeId === editor.typeId,
isVisible: () => (this.shell.currentWidget as VesEditorsWidget)?.typeId === editor.typeId,
execute: () => (this.shell.currentWidget as VesEditorsWidget)?.dispatchCommandEvent(command.id),
});
Expand Down Expand Up @@ -236,10 +238,6 @@ export class VesEditorsViewContribution extends AbstractViewContribution<VesEdit
for (const typeId of Object.keys(types || {})) {
const type = types![typeId];

// TODO: disabled for now since the Save As command is not working for
// untitled editors files. Need to investigate why that is the case.
/*
// contribute to "Create: New File..."" command
if (type.file?.startsWith('.')) {
const id = `editors.new-untitled.${typeId}`;
menus.registerMenuNode(CommonMenus.FILE_NEW_CONTRIBUTIONS, {
Expand All @@ -248,7 +246,6 @@ export class VesEditorsViewContribution extends AbstractViewContribution<VesEdit
command: id,
});
}
*/

if (type.forFiles?.length) {
menus.registerMenuAction(NavigatorContextMenu.NAVIGATION, {
Expand Down

0 comments on commit 529ebc4

Please sign in to comment.