File tree 4 files changed +18
-3
lines changed
4 files changed +18
-3
lines changed Original file line number Diff line number Diff line change @@ -189,6 +189,7 @@ let main () =
189
189
Printf. printf " \" %s\" " (Json. escape (Commands. format ~path ))
190
190
| [_; " test" ; path] ->
191
191
Cfg. supportsSnippets := true ;
192
+ Cfg. isTestMode := true ;
192
193
Commands. test ~path
193
194
| args when List. mem " -h" args || List. mem " --help" args -> prerr_endline help
194
195
| _ ->
Original file line number Diff line number Diff line change @@ -3,3 +3,5 @@ let supportsSnippets = ref false
3
3
let debugFollowCtxPath = ref false
4
4
5
5
let isDocGenFromCompiler = ref false
6
+
7
+ let isTestMode = ref false
Original file line number Diff line number Diff line change @@ -112,7 +112,10 @@ let definition ~path ~pos ~debug =
112
112
if skipLoc then None
113
113
else
114
114
Some
115
- {Protocol. uri = Uri. toString uri; range = Utils. cmtLocToRange loc}
115
+ {
116
+ Protocol. uri = Files. canonicalizeUri uri;
117
+ range = Utils. cmtLocToRange loc;
118
+ }
116
119
| Some _ -> None ))
117
120
in
118
121
print_endline
@@ -132,7 +135,10 @@ let typeDefinition ~path ~pos ~debug =
132
135
| None -> None
133
136
| Some (uri , loc ) ->
134
137
Some
135
- {Protocol. uri = Uri. toString uri; range = Utils. cmtLocToRange loc}))
138
+ {
139
+ Protocol. uri = Files. canonicalizeUri uri;
140
+ range = Utils. cmtLocToRange loc;
141
+ }))
136
142
in
137
143
print_endline
138
144
(match maybeLocation with
Original file line number Diff line number Diff line change @@ -20,7 +20,7 @@ let relpath base path =
20
20
let baselen = String. length base in
21
21
let rest = String. sub path baselen (String. length path - baselen) in
22
22
(if rest <> " " && rest.[0 ] = Filename. dir_sep.[0 ] then sliceToEnd rest 1
23
- else rest)
23
+ else rest)
24
24
|> removeExtraDots
25
25
else
26
26
let rec loop bp pp =
@@ -102,3 +102,9 @@ let classifySourceFile path =
102
102
if Filename. check_suffix path " .res" && exists path then Res
103
103
else if Filename. check_suffix path " .resi" && exists path then Resi
104
104
else Other
105
+
106
+ let canonicalizeUri uri =
107
+ if Cfg. isTestMode.contents then uri |> Uri. toString
108
+ else
109
+ let path = Uri. toPath uri in
110
+ path |> Unix. realpath
You can’t perform that action at this time.
0 commit comments