Skip to content

Commit

Permalink
Fix bug in resolving relative paths for occurrences
Browse files Browse the repository at this point in the history
  • Loading branch information
liam923 committed Oct 8, 2024
1 parent 085ca52 commit ee27818
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/analysis/occurrences.ml
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,10 @@ let locs_of ~config ~env ~typer_result ~pos ~scope path =
is not necessary for correctness, it makes the output a bit nicer. *)
let canonicalize_file_in_loc ({ txt; loc } : 'a Location.loc) :
'a Location.loc =
let file = Misc.canonicalize_filename loc.loc_start.pos_fname in
let file =
Misc.canonicalize_filename ?cwd:config.merlin.source_root
loc.loc_start.pos_fname
in
{ txt; loc = set_fname ~file loc }
in
let locs = Lid_set.map canonicalize_file_in_loc locs in
Expand Down
5 changes: 2 additions & 3 deletions tests/test-dirs/occurrences/project-wide/pwo-relative.t
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,11 @@ Configure merlin
> EOF

Perform the occurrences query
TODO: some of these filepaths are wrong
$ ( cd main ; $MERLIN single occurrences -scope project -identifier-at 1:13 \
> -filename main.ml < main.ml | jq .value )
[
{
"file": "$TESTCASE_ROOT/main/lib/foo.ml",
"file": "$TESTCASE_ROOT/lib/foo.ml",
"start": {
"line": 1,
"col": 4
Expand All @@ -61,7 +60,7 @@ TODO: some of these filepaths are wrong
}
},
{
"file": "$TESTCASE_ROOT/main/lib/foo.ml",
"file": "$TESTCASE_ROOT/lib/foo.ml",
"start": {
"line": 2,
"col": 22
Expand Down

0 comments on commit ee27818

Please sign in to comment.