Skip to content

Commit ab56eea

Browse files
committed
Make reconstruct identifier more robust
It's always correct to have a space after the parenthesis and it is sometimes necessary, for infix operators that start with `*` for example.
1 parent a687b15 commit ab56eea

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/frontend/query_commands.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ let reconstruct_identifier pipeline pos = function
221221
(dot.[0] >= 'a' && dot.[0] <= 'z') ||
222222
(dot.[0] >= 'A' && dot.[0] <= 'Z')
223223
then dot
224-
else "(" ^ dot ^ ")"
224+
else "( " ^ dot ^ ")"
225225
in
226226
begin match path with
227227
| [] -> []
@@ -507,9 +507,9 @@ let dispatch pipeline (type a) : a Query_protocol.t -> a =
507507
let typer = Mpipeline.typer_result pipeline in
508508
let pos = Mpipeline.get_lexing_pos pipeline pos in
509509
let node = Mtyper.node_at typer pos in
510-
let res = Syntax_doc.get_syntax_doc pos node in
510+
let res = Syntax_doc.get_syntax_doc pos node in
511511
(match res with
512-
| Some res -> `Found res
512+
| Some res -> `Found res
513513
| None -> `No_documentation)
514514

515515
| Locate (patho, ml_or_mli, pos) ->

tests/test-dirs/type-enclosing/need-parens.t

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ FIXME: locate on `M.( |* )` should work:
4242
> module M = struct let ( * ) a b = a + b end
4343
> let _ = M.( * )
4444
> EOF
45-
"Comment not terminated"
45+
"Not in environment 'M.*'"
4646

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

0 commit comments

Comments
 (0)