Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ unreleased

+ merlin binary
- Update internal typer to match OCaml 4.14.1 release. (#1557)
- fix locate calls on infix operators (#1445, fixes #949)

merlin 4.7
==========
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/locate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ let from_path ~config ~env ~namespace ml_or_mli path =
let from_string ~config ~env ~local_defs ~pos ?namespaces switch path =
File_switching.reset ();
let browse = Mbrowse.of_typedtree local_defs in
let lid = Longident.parse path in
let lid = Misc_utils.parse_longident path in
let ident, is_label = Longident.keep_suffix lid in
match
match namespaces with
Expand Down
8 changes: 7 additions & 1 deletion src/analysis/misc_utils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ end = struct
maybe_replace_name ?name (Untypeast.lident_of_path path)
end


let parenthesize_name name =
(* Qualified operators need parentheses *)
if name = "" || not (Oprint.parenthesized_ident name) then name else (
Expand All @@ -57,3 +56,10 @@ let parenthesize_name name =
else
"(" ^ name ^ ")"
)

let parse_longident name =
let l =
if name.[String.length name - 1] = '.' then [name]
else String.split_on_char ~sep:'.' name
in
Longident.unflatten l |> Option.get
4 changes: 4 additions & 0 deletions src/analysis/misc_utils.mli
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ end

(* Add parenthesis to qualified operators *)
val parenthesize_name : string -> string

(* Uses [Longident.unflatten] to parse a longident while preserving infix
identifiers *)
val parse_longident : string -> Longident.t
2 changes: 1 addition & 1 deletion src/analysis/type_enclosing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ let from_reconstructed ~nodes ~cursor ~verbosity exprs =
let get_context lident =
Context.inspect_browse_tree
~cursor
(Longident.parse lident)
(Misc_utils.parse_longident lident)
[nodes]
in

Expand Down
2 changes: 0 additions & 2 deletions tests/test-dirs/locate/issue949.t/issue949.ml

This file was deleted.

16 changes: 14 additions & 2 deletions tests/test-dirs/locate/issue949.t/run.t
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
This test is for testing the behavior of identifiers with a . in them:

$ $MERLIN single locate -look-for ml -position 2:16 ./issue949.ml < ./issue949.ml
$ cat >issue949.ml <<EOF
> module A = struct let (+.) a b = a +. b end
> let f x = A.(x +. 1.)
> EOF


$ $MERLIN single locate -look-for ml -position 2:16 ./issue949.ml <./issue949.ml
{
"class": "return",
"value": "Not in environment ''",
"value": {
"file": "*buffer*",
"pos": {
"line": 1,
"col": 22
}
},
"notifications": []
}