File tree 1 file changed +20
-0
lines changed
1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -37,6 +37,12 @@ export namespace VimCellManager {
37
37
}
38
38
}
39
39
40
+ interface IUndoOptions {
41
+ repeat : number ;
42
+ repeatIsExplicit : boolean ;
43
+ registerName : unknown ;
44
+ }
45
+
40
46
export class VimEditorManager {
41
47
constructor ( { enabled, userKeybindings } : VimEditorManager . IOptions ) {
42
48
this . enabled = enabled ;
@@ -89,6 +95,20 @@ export class VimEditorManager {
89
95
return view . hasFocus ;
90
96
} ;
91
97
}
98
+
99
+ // Override vim-mode undo/redo to make it work with JupyterLab RTC-aware
100
+ // history; it needs to happen on every chang of the editor.
101
+ Vim . defineAction ( 'undo' , ( cm : CodeMirror , options : IUndoOptions ) => {
102
+ for ( let i = 0 ; i < options . repeat ; i ++ ) {
103
+ editor ! . undo ( ) ;
104
+ }
105
+ } ) ;
106
+ Vim . defineAction ( 'redo' , ( cm : CodeMirror , options : IUndoOptions ) => {
107
+ for ( let i = 0 ; i < options . repeat ; i ++ ) {
108
+ editor ! . redo ( ) ;
109
+ }
110
+ } ) ;
111
+
92
112
const lcm = getCM ( view ) ;
93
113
94
114
// Clear existing user keybindings, then re-register in case they changed in the user settings
You can’t perform that action at this time.
0 commit comments