Skip to content

Commit

Permalink
Make reconstruct identifier more robust
Browse files Browse the repository at this point in the history
It's always correct to have a space after the parenthesis and it is sometimes
necessary, for infix operators that start with `*` for example.
  • Loading branch information
voodoos committed May 2, 2024
1 parent a687b15 commit ab56eea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/frontend/query_commands.ml
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ let reconstruct_identifier pipeline pos = function
(dot.[0] >= 'a' && dot.[0] <= 'z') ||
(dot.[0] >= 'A' && dot.[0] <= 'Z')
then dot
else "(" ^ dot ^ ")"
else "( " ^ dot ^ ")"
in
begin match path with
| [] -> []
Expand Down Expand Up @@ -507,9 +507,9 @@ let dispatch pipeline (type a) : a Query_protocol.t -> a =
let typer = Mpipeline.typer_result pipeline in
let pos = Mpipeline.get_lexing_pos pipeline pos in
let node = Mtyper.node_at typer pos in
let res = Syntax_doc.get_syntax_doc pos node in
let res = Syntax_doc.get_syntax_doc pos node in
(match res with
| Some res -> `Found res
| Some res -> `Found res
| None -> `No_documentation)

| Locate (patho, ml_or_mli, pos) ->
Expand Down
4 changes: 2 additions & 2 deletions tests/test-dirs/type-enclosing/need-parens.t
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ FIXME: locate on `M.( |* )` should work:
> module M = struct let ( * ) a b = a + b end
> let _ = M.( * )
> EOF
"Comment not terminated"
"Not in environment 'M.*'"

And need spaces:
FIXME: locate on `M.( *| )` should work:
Expand All @@ -51,4 +51,4 @@ FIXME: locate on `M.( *| )` should work:
> module M = struct let ( * ) a b = a + b end
> let _ = M.( * )
> EOF
"Comment not terminated"
"Not in environment 'M.*'"

0 comments on commit ab56eea

Please sign in to comment.