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 ;
@@ -90,6 +96,20 @@ export class VimEditorManager {
90
96
return view . hasFocus ;
91
97
} ;
92
98
}
99
+
100
+ // Override vim-mode undo/redo to make it work with JupyterLab RTC-aware
101
+ // history; it needs to happen on every chang of the editor.
102
+ Vim . defineAction ( 'undo' , ( cm : CodeMirror , options : IUndoOptions ) => {
103
+ for ( let i = 0 ; i < options . repeat ; i ++ ) {
104
+ editor ! . undo ( ) ;
105
+ }
106
+ } ) ;
107
+ Vim . defineAction ( 'redo' , ( cm : CodeMirror , options : IUndoOptions ) => {
108
+ for ( let i = 0 ; i < options . repeat ; i ++ ) {
109
+ editor ! . redo ( ) ;
110
+ }
111
+ } ) ;
112
+
93
113
const lcm = getCM ( view ) ;
94
114
95
115
// 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