diff --git a/src/analysis/context.ml b/src/analysis/context.ml index 7d0e1a433b..7fba149868 100644 --- a/src/analysis/context.ml +++ b/src/analysis/context.ml @@ -72,7 +72,8 @@ let cursor_on_longident_end let name_lenght = String.length name in if Pprintast.needs_parens name then name_lenght + 2 - else name_lenght + else + name_lenght in let constr_pos = { loc.loc_end diff --git a/src/ocaml/parsing/pprintast.mli b/src/ocaml/parsing/pprintast.mli index 4ceb5bbbb9..c9f5393dc2 100644 --- a/src/ocaml/parsing/pprintast.mli +++ b/src/ocaml/parsing/pprintast.mli @@ -57,3 +57,4 @@ val tyvar: Format.formatter -> string -> unit (* merlin *) val case_list : Format.formatter -> Parsetree.case list -> unit val protect_ident : Format.formatter -> string -> unit +val needs_parens : string -> bool diff --git a/tests/test-dirs/type-enclosing/need-parens.t b/tests/test-dirs/type-enclosing/need-parens.t index 21954932e1..4755f196d2 100644 --- a/tests/test-dirs/type-enclosing/need-parens.t +++ b/tests/test-dirs/type-enclosing/need-parens.t @@ -4,7 +4,13 @@ FIXME: locate on `M.(|+)` should work: > module M = struct let (+) a b = a + b end > let _ = M.(+) > EOF - "Not in environment 'M.+'" + { + "file": "test.ml", + "pos": { + "line": 1, + "col": 22 + } + } Locate on `M.(+|)` should work: $ $MERLIN single locate -position 2:12 -filename test.ml <<'EOF' | \