File tree Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Expand file tree Collapse file tree 3 files changed +44
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ export enum IpcEvents {
2929 CONFIRM_QUIT = 'CONFIRM_QUIT' ,
3030 GET_APP_PATHS = 'GET_APP_PATHS' ,
3131 SELECT_ALL_IN_EDITOR = 'SELECT_ALL_IN_EDITOR' ,
32+ UNDO_IN_EDITOR = 'UNDO_IN_EDITOR' ,
33+ REDO_IN_EDITOR = 'REDO_IN_EDITOR' ,
3234 BLOCK_ACCELERATORS = 'BLOCK_ACCELERATORS' ,
3335 SET_SHOW_ME_TEMPLATE = 'SET_SHOW_ME_TEMPLATE' ,
3436 CLICK_TITLEBAR_MAC = 'CLICK_TITLEBAR_MAC' ,
@@ -79,6 +81,8 @@ export const ipcRendererEvents = [
7981 IpcEvents . BEFORE_QUIT ,
8082 IpcEvents . GET_APP_PATHS ,
8183 IpcEvents . SELECT_ALL_IN_EDITOR ,
84+ IpcEvents . UNDO_IN_EDITOR ,
85+ IpcEvents . REDO_IN_EDITOR ,
8286 IpcEvents . SET_SHOW_ME_TEMPLATE ,
8387 IpcEvents . TASK_BISECT ,
8488 IpcEvents . TASK_TEST ,
Original file line number Diff line number Diff line change @@ -339,6 +339,28 @@ export function setupMenu(options?: SetUpMenuOptions) {
339339 Menu . sendActionToFirstResponder ( 'selectAll:' ) ;
340340 }
341341 } ;
342+
343+ const undo = item . submenu . find ( ( i ) => i . label === 'Undo' ) ! ;
344+ delete undo . role ; // override default role
345+ undo . click = ( ) => {
346+ ipcMainManager . send ( IpcEvents . UNDO_IN_EDITOR ) ;
347+
348+ // Allow undo to occur in text fields outside the editors.
349+ if ( process . platform === 'darwin' ) {
350+ Menu . sendActionToFirstResponder ( 'undo:' ) ;
351+ }
352+ } ;
353+
354+ const redo = item . submenu . find ( ( i ) => i . label === 'Redo' ) ! ;
355+ delete redo . role ; // override default role
356+ redo . click = ( ) => {
357+ ipcMainManager . send ( IpcEvents . REDO_IN_EDITOR ) ;
358+
359+ // Allow redo to occur in text fields outside the editors.
360+ if ( process . platform === 'darwin' ) {
361+ Menu . sendActionToFirstResponder ( 'redo:' ) ;
362+ }
363+ } ;
342364 }
343365
344366 // Tweak "View" menu
Original file line number Diff line number Diff line change @@ -95,6 +95,22 @@ export const Editors = observer(
9595 } ,
9696 ) ;
9797
98+ ipcRendererManager . on ( IpcEvents . REDO_IN_EDITOR , ( _event ) => {
99+ const editor = this . props . appState . editorMosaic . focusedEditor ( ) ;
100+ if ( editor ) {
101+ const model = editor . getModel ( ) ;
102+ if ( model ) ( model as any ) . redo ( ) ;
103+ }
104+ } ) ;
105+
106+ ipcRendererManager . on ( IpcEvents . UNDO_IN_EDITOR , ( _event ) => {
107+ const editor = this . props . appState . editorMosaic . focusedEditor ( ) ;
108+ if ( editor ) {
109+ const model = editor . getModel ( ) ;
110+ if ( model ) ( model as any ) . undo ( ) ;
111+ }
112+ } ) ;
113+
98114 ipcRendererManager . on ( IpcEvents . SELECT_ALL_IN_EDITOR , ( _event ) => {
99115 const editor = this . props . appState . editorMosaic . focusedEditor ( ) ;
100116 if ( editor ) {
@@ -116,6 +132,8 @@ export const Editors = observer(
116132 ipcRendererManager . removeAllListeners ( IpcEvents . FS_NEW_TEST ) ;
117133 ipcRendererManager . removeAllListeners ( IpcEvents . MONACO_TOGGLE_OPTION ) ;
118134 ipcRendererManager . removeAllListeners ( IpcEvents . SELECT_ALL_IN_EDITOR ) ;
135+ ipcRendererManager . removeAllListeners ( IpcEvents . UNDO_IN_EDITOR ) ;
136+ ipcRendererManager . removeAllListeners ( IpcEvents . REDO_IN_EDITOR ) ;
119137 }
120138
121139 /**
You can’t perform that action at this time.
0 commit comments