Skip to content

Commit

Permalink
GH-210: Restored undo/redo functionality.
Browse files Browse the repository at this point in the history
Signed-off-by: Akos Kitta <[email protected]>
  • Loading branch information
kittaakos committed Sep 1, 2017
1 parent 86103e6 commit b4ed54f
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
58 changes: 58 additions & 0 deletions packages/core/src/common/commands-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { CommandContribution, CommandRegistry } from './command';
import { injectable } from "inversify";

export namespace CommonCommands {
<<<<<<< Upstream, based on branch 'GH-210' of https://github.com/theia-ide/theia.git

export const EDIT_MENU = "2_edit";
export const EDIT_MENU_UNDO_GROUP = "1_undo/redo";
Expand Down Expand Up @@ -102,6 +103,63 @@ export class CommonCommandContribution implements CommandContribution {
id: CommonCommands.EDIT_REPLACE,
label: 'Replace'
});
=======
export const EDIT_MENU = "2_edit"
export const EDIT_MENU_UNDO_GROUP = "1_undo/redo"
export const EDIT_MENU_COPYPASTE_GROUP = "2_copy"

export const EDIT_CUT = 'edit_cut';
export const EDIT_COPY = 'edit_copy';
export const EDIT_PASTE = 'edit_paste';

export const EDIT_UNDO = 'undo';
export const EDIT_REDO = 'redo';
}

@injectable()
export class CommonMenuContribution implements MenuContribution {

registerMenus(registry: MenuModelRegistry): void {
// Explicitly register the Edit Submenu
registry.registerSubmenu([MAIN_MENU_BAR], CommonCommands.EDIT_MENU, "Edit");
registry.registerMenuAction([MAIN_MENU_BAR, CommonCommands.EDIT_MENU, CommonCommands.EDIT_MENU_UNDO_GROUP], {
commandId: CommonCommands.EDIT_UNDO
});
registry.registerMenuAction([
MAIN_MENU_BAR,
CommonCommands.EDIT_MENU,
CommonCommands.EDIT_MENU_UNDO_GROUP], {
commandId: CommonCommands.EDIT_REDO
});
}

}

@injectable()
export class CommonCommandContribution implements CommandContribution {

registerCommands(commandRegistry: CommandRegistry): void {
commandRegistry.registerCommand({
id: CommonCommands.EDIT_CUT,
label: 'Cut'
})
commandRegistry.registerCommand({
id: CommonCommands.EDIT_COPY,
label: 'Copy',
})
commandRegistry.registerCommand({
id: CommonCommands.EDIT_PASTE,
label: 'Paste'
})
commandRegistry.registerCommand({
id: CommonCommands.EDIT_UNDO,
label: 'Undo'
})
commandRegistry.registerCommand({
id: CommonCommands.EDIT_REDO,
label: 'Redo'
})
>>>>>>> 21b1906 GH-210: Restored undo/redo functionality.
}

}
6 changes: 6 additions & 0 deletions packages/monaco/src/browser/monaco-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,13 @@ export class MonacoEditorCommandHandlers implements CommandContribution {
});

[CommonCommands.EDIT_UNDO, CommonCommands.EDIT_REDO].forEach(id => {
<<<<<<< Upstream, based on branch 'GH-210' of https://github.com/theia-ide/theia.git
const doExecute = (editor: MonacoEditor, ...args: any[]): any => editor.getControl().cursor.trigger('keyboard', id, args);
=======
const doExecute = (editor: MonacoEditor, ...args: any[]): any => {
return editor.getControl().cursor.trigger('keyboard', id, args);
};
>>>>>>> 21b1906 GH-210: Restored undo/redo functionality.
const handler = this.newClipboardHandler(id, doExecute);
commands.registerHandler(id, handler);
});
Expand Down

0 comments on commit b4ed54f

Please sign in to comment.