88 ViewPlugin ,
99 type ViewUpdate ,
1010} from "@codemirror/view" ;
11- import { getVimModule } from "../vim_loader.ts" ;
1211import { createCommandKeyBindings } from "../codemirror/editor_state.ts" ;
1312
1413type MiniEditorEvents = {
@@ -23,9 +22,7 @@ type MiniEditorEvents = {
2322export function MiniEditor ( {
2423 text,
2524 placeholderText,
26- vimMode,
2725 darkMode,
28- vimStartInInsertMode,
2926 onBlur,
3027 onEscape,
3128 onKeyUp,
@@ -37,15 +34,12 @@ export function MiniEditor({
3734} : {
3835 text : string ;
3936 placeholderText ?: string ;
40- vimMode : boolean ;
4137 darkMode ?: boolean ;
42- vimStartInInsertMode ?: boolean ;
4338 focus ?: boolean ;
4439 editable : boolean ;
4540} & MiniEditorEvents ) {
4641 const editorDiv = useRef < HTMLDivElement > ( null ) ;
4742 const editorViewRef = useRef < EditorView > ( ) ;
48- const vimModeRef = useRef < string > ( "normal" ) ;
4943 // TODO: This super duper ugly, but I don't know how to avoid it
5044 // Due to how MiniCodeEditor is built, it captures the closures of all callback functions
5145 // which results in them pointing to old state variables, to avoid this we do this...
@@ -102,7 +96,7 @@ export function MiniEditor({
10296 } ) ;
10397 }
10498 }
105- } , [ text , vimMode ] ) ;
99+ } , [ text ] ) ;
106100
107101 let onBlurred = false ,
108102 onEntered = false ;
@@ -128,31 +122,11 @@ export function MiniEditor({
128122 ) ;
129123
130124 function buildEditorState ( ) {
131- // When vim mode is active, we need for CM to have created the new state
132- // and the subscribe to the vim mode's events
133- // This needs to happen in the next tick, so we wait a tick with setTimeout
134- const vimMod = getVimModule ( ) ;
135- if ( vimMode && vimMod ) {
136- // Only applies to vim mode
137- setTimeout ( ( ) => {
138- const cm = vimMod . getCM ( editorViewRef . current ! ) ! ;
139- cm . on ( "vim-mode-change" , ( { mode } : { mode : string } ) => {
140- vimModeRef . current = mode ;
141- } ) ;
142- if ( vimStartInInsertMode ) {
143- vimMod . Vim . handleKey ( cm , "i" , "+input" ) ;
144- }
145- } ) ;
146- }
147125 return EditorState . create ( {
148126 doc : text ,
149127 extensions : [
150128 EditorView . theme ( { } , { dark : darkMode } ) ,
151- // Insert command bindings before vim-mode to ensure they're available
152- // in normal mode. See editor_state.ts for more details.
153129 createCommandKeyBindings ( globalThis . client ) ,
154- // Enable vim mode, or not (uses already-loaded module if available)
155- [ ...( vimMode && vimMod ? [ vimMod . vim ( ) ] : [ ] ) ] ,
156130 [
157131 ...( editable
158132 ? [ ]
@@ -195,12 +169,7 @@ export function MiniEditor({
195169 return false ;
196170 }
197171 if ( event . key === "Enter" ) {
198- // Enter should be handled by the keymap, except when in Vim normal mode
199- // because then it's disabled
200- if ( vimMode && vimModeRef . current === "normal" ) {
201- onEnterHandler ( view , event . shiftKey ) ;
202- return true ;
203- }
172+ // Enter should be handled by the keymap
204173 return false ;
205174 }
206175 if ( callbacksRef . current ! . onKeyUp ) {
0 commit comments