File tree 5 files changed +21
-4
lines changed
5 files changed +21
-4
lines changed Original file line number Diff line number Diff line change 15
15
#### :bug : Bug Fix
16
16
17
17
- Fix highlighting of other languages being affected by rescript-vscode. https://github.com/rescript-lang/rescript-vscode/pull/973
18
+ - Use canonicalized URIs/paths for jump to definition. https://github.com/rescript-lang/rescript-vscode/pull/982
18
19
19
20
#### :nail_care : Polish
20
21
Original file line number Diff line number Diff line change @@ -191,7 +191,9 @@ let main () =
191
191
(Json. escape (CreateInterface. command ~path ~cmi File))
192
192
| [_; " format" ; path] ->
193
193
Printf. printf " \" %s\" " (Json. escape (Commands. format ~path ))
194
- | [_; " test" ; path] -> Commands. test ~path
194
+ | [_; " test" ; path] ->
195
+ Cfg. isTestMode := true ;
196
+ Commands. test ~path
195
197
| args when List. mem " -h" args || List. mem " --help" args -> prerr_endline help
196
198
| _ ->
197
199
prerr_endline help;
Original file line number Diff line number Diff line change 1
1
let debugFollowCtxPath = ref false
2
2
3
3
let isDocGenFromCompiler = ref false
4
+
5
+ let isTestMode = ref false
Original file line number Diff line number Diff line change @@ -144,7 +144,10 @@ let definition ~path ~pos ~debug =
144
144
if skipLoc then None
145
145
else
146
146
Some
147
- {Protocol. uri = Uri. toString uri; range = Utils. cmtLocToRange loc}
147
+ {
148
+ Protocol. uri = Files. canonicalizeUri uri;
149
+ range = Utils. cmtLocToRange loc;
150
+ }
148
151
| Some _ -> None ))
149
152
in
150
153
print_endline
@@ -164,7 +167,10 @@ let typeDefinition ~path ~pos ~debug =
164
167
| None -> None
165
168
| Some (uri , loc ) ->
166
169
Some
167
- {Protocol. uri = Uri. toString uri; range = Utils. cmtLocToRange loc}))
170
+ {
171
+ Protocol. uri = Files. canonicalizeUri uri;
172
+ range = Utils. cmtLocToRange loc;
173
+ }))
168
174
in
169
175
print_endline
170
176
(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