Skip to content

Commit

Permalink
Fix the issue by relying on the heuristic when at origin.
Browse files Browse the repository at this point in the history
There might still be a problem when the comment is associated to the declaration.
  • Loading branch information
voodoos committed Feb 23, 2023
1 parent f1d8322 commit fd62de1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 5 additions & 2 deletions src/analysis/locate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,9 @@ let get_doc ~config ~env ~local_defs ~comments ~pos =
{ loc_start = pos; loc_end = pos; loc_ghost = true }
in
from_uid ~loc uid
| `At_origin | `Missing_labels_namespace -> `No_documentation
| `At_origin ->
`Found { loc_start = pos; loc_end = pos; loc_ghost = true }
| `Missing_labels_namespace -> `No_documentation
| `Builtin _ -> `Builtin
| (`Not_in_env _ | `Not_found _ |`File_not_found _ )
as otherwise -> otherwise
Expand Down Expand Up @@ -966,7 +968,8 @@ let get_doc ~config ~env ~local_defs ~comments ~pos =
let (_, deepest_before) =
Mbrowse.(leaf_node @@ deepest_before loc.loc_start [browse])
in
(* based on https://v2.ocaml.org/manual/doccomments.html#ss:label-comments: *)
(* based on:
https://v2.ocaml.org/manual/doccomments.html#ss:label-comments: *)
let after_only = begin match deepest_before with
| Browse_raw.Constructor_declaration _ -> true
(* The remaining `true` cases are currently not reachable *)
Expand Down
3 changes: 1 addition & 2 deletions tests/test-dirs/document/issue1540.t
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
> let _ = id ()
> EOF
FIXME: Merlin should return the docstring
$ $MERLIN single document -position 2:5 \
> -filename doc.ml <doc.ml | jq '.value'
"No documentation available"
"whatever"
$ $MERLIN single document -position 3:9 \
> -filename doc.ml <doc.ml | jq '.value'
Expand Down

0 comments on commit fd62de1

Please sign in to comment.