Skip to content

Commit

Permalink
context: improve cursor position detection
Browse files Browse the repository at this point in the history
  • Loading branch information
voodoos committed May 2, 2024
1 parent 575e96a commit 3024444
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/analysis/context.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/ocaml/parsing/pprintast.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 7 additions & 1 deletion tests/test-dirs/type-enclosing/need-parens.t
Original file line number Diff line number Diff line change
Expand Up @@ -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' | \
Expand Down

0 comments on commit 3024444

Please sign in to comment.