@@ -80,8 +80,8 @@ let signatureHelp ~path ~pos ~currentFile ~debug =
8080 in
8181 print_endline (Protocol. stringifySignatureHelp result)
8282
83- let codeAction ~path ~pos ~currentFile ~debug =
84- Xform. extractCodeActions ~path ~pos ~current File ~debug
83+ let codeAction ~path ~startPos ~ endPos ~currentFile ~debug =
84+ Xform. extractCodeActions ~path ~start Pos ~end Pos ~current File ~debug
8585 |> CodeActions. stringifyCodeActions |> print_endline
8686
8787let definition ~path ~pos ~debug =
@@ -268,7 +268,9 @@ let test ~path =
268268 let lines = text |> String. split_on_char '\n' in
269269 let processLine i line =
270270 let createCurrentFile () =
271- let currentFile, cout = Filename. open_temp_file " def" " txt" in
271+ let currentFile, cout =
272+ Filename. open_temp_file " def" (" txt." ^ Filename. extension path)
273+ in
272274 let removeLineComment l =
273275 let len = String. length l in
274276 let rec loop i =
@@ -372,13 +374,24 @@ let test ~path =
372374 ^ string_of_int col);
373375 typeDefinition ~path ~pos: (line, col) ~debug: true
374376 | "xfm" ->
375- print_endline
376- (" Xform " ^ path ^ " " ^ string_of_int line ^ " :"
377- ^ string_of_int col);
377+ let currentFile = createCurrentFile () in
378+ (* +2 is to ensure that the character ^ points to is what's considered the end of the selection. *)
379+ let endCol = col + try String. index rest '^' + 2 with _ -> 0 in
380+ let endPos = (line, endCol) in
381+ let startPos = (line, col) in
382+ if startPos = endPos then
383+ print_endline
384+ (" Xform " ^ path ^ " " ^ string_of_int line ^ " :"
385+ ^ string_of_int col)
386+ else
387+ print_endline
388+ (" Xform " ^ path ^ " start: " ^ Pos. toString startPos
389+ ^ " , end: " ^ Pos. toString endPos);
378390 let codeActions =
379- Xform. extractCodeActions ~path ~pos: (line, col) ~current File:path
391+ Xform. extractCodeActions ~path ~start Pos ~end Pos ~current File
380392 ~debug: true
381393 in
394+ Sys. remove currentFile;
382395 codeActions
383396 |> List. iter (fun {Protocol. title; edit = {documentChanges} } ->
384397 Printf. printf " Hit: %s\n " title;
0 commit comments