@@ -162,13 +162,68 @@ module Effects = {
162162 );
163163 });
164164 };
165+
166+ let command = cmd => {
167+ Isolinear . Effect . createWithDispatch(
168+ ~name= "Feature_Vim.Effect.command" , dispatch => {
169+ let context = Vim . Context . current() ;
170+ let (newContext , effects ) = Vim . command(~context, cmd);
171+
172+ dispatch(
173+ ModeChanged ({
174+ allowAnimation: false ,
175+ mode: newContext. mode,
176+ subMode: newContext. subMode,
177+ effects,
178+ }),
179+ );
180+ });
181+ };
165182};
166183
167- let update = (msg, model: model ) => {
184+ let update = (~cursor , ~selections , msg, model: model ) => {
168185 switch (msg) {
169186 | Command (command ) =>
170- prerr_endline("COMMAND: " ++ show_command(command));
171- failwith ("Done" );
187+ let (startLine , stopLine ) =
188+ switch (selections) {
189+ | [ visualRange , ... _ ] =>
190+ let range = Oni_Core . VisualRange . (visualRange. range);
191+ ByteRange . (range. start. line, range. stop. line);
192+ | [] => BytePosition . (cursor. line, cursor. line)
193+ };
194+ let cmd =
195+ switch (command) {
196+ | MoveSelectionDownward
197+ | MoveSelectionUpward => "m"
198+
199+ | CopySelectionDownward
200+ | CopySelectionUpward => "t"
201+ };
202+
203+ let destination =
204+ EditorCoreTypes . (
205+ switch (command) {
206+ | MoveSelectionDownward => LineNumber . (stopLine + 1 )
207+ | MoveSelectionUpward => LineNumber . (startLine - 2 )
208+ | CopySelectionUpward => LineNumber . (startLine - 1 )
209+ | CopySelectionDownward => stopLine
210+ }
211+ );
212+
213+ let eff =
214+ EditorCoreTypes . (
215+ Effects . command(
216+ Printf . sprintf(
217+ "% s ,% s % s % d " ,
218+ startLine |> LineNumber . toOneBased |> string_of_int,
219+ stopLine |> LineNumber . toOneBased |> string_of_int,
220+ cmd,
221+ destination |> LineNumber . toOneBased,
222+ ),
223+ )
224+ );
225+
226+ (model, Effect (eff));
172227
173228 | ModeChanged ({allowAnimation, mode, effects, subMode}) => (
174229 {... model, subMode} |> handleEffects(effects),
@@ -278,14 +333,6 @@ let sub = (~buffer, ~topVisibleLine, ~bottomVisibleLine, model) => {
278333module Commands = {
279334 open Feature_Commands . Schema ;
280335
281- let moveLinesDown =
282- define(
283- ~category= "Editor" ,
284- ~title= "Move lines down" ,
285- "editor.action.moveLinesDownAction" ,
286- Command (MoveSelectionDownward ),
287- );
288-
289336 let moveLinesDown =
290337 define(
291338 ~title= "Move Line Down" ,
0 commit comments