Skip to content

Commit 3d3eb8a

Browse files
tatchirgrinberg
authored andcommitted
fix: locations of symbols the workspace
use filname from the Browse_raw.node location
1 parent 6caad6c commit 3d3eb8a

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Unreleased
2+
3+
## Fixes
4+
5+
- Fix workspace symbols that could have a wrong path in some cases ([#675](https://github.com/ocaml/ocaml-lsp/pull/671))
6+
17
# 1.10.6
28

39
## Fixes

ocaml-lsp-server/src/workspace_symbol.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,15 +213,16 @@ let symbols_from_cm_file ~filter root_uri cm_file =
213213
| Some sourcefile -> (
214214
match Filename.extension sourcefile with
215215
| ".ml" | ".mli" -> (
216-
let sourcepath = Filename.concat root_uri sourcefile in
217216
match browse_of_cmt cmt with
218217
| None -> []
219218
| Some browse ->
220219
let outline =
221220
let browse_tree = Merlin_analysis.Browse_tree.of_node browse in
222221
Outline.get [ browse_tree ]
223222
in
224-
let uri = Uri.of_path sourcepath in
223+
let loc = Mbrowse.node_loc browse in
224+
let fname = loc.loc_start.pos_fname in
225+
let uri = Uri.of_path (Filename.concat root_uri fname) in
225226
filter (Document_symbol.symbols_of_outline uri outline))
226227
| _ -> [])
227228

ocaml-lsp-server/test/e2e/__tests__/workspace-symbol.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ describe("workspace/symbol", () => {
107107
"user 15 file://<workspace_symbol_A>/lib/lib.ml 3:0 5:1",
108108
"name 7 file://<workspace_symbol_A>/lib/lib.ml 4:2 4:14",
109109
"t 15 file://<workspace_symbol_A>/lib/LibTypes.mli 0:0 0:15",
110-
"x 12 file://<workspace_symbol_A>/lib/vendored_lib.ml 0:0 0:9",
110+
"x 12 file://<workspace_symbol_A>/vendor/vendored_lib.ml 0:0 0:9",
111111
]
112112
`);
113113
});
@@ -187,7 +187,7 @@ describe("workspace/symbol", () => {
187187
"user 15 file://<workspace_symbol_A>/lib/lib.ml 3:0 5:1",
188188
"name 7 file://<workspace_symbol_A>/lib/lib.ml 4:2 4:14",
189189
"t 15 file://<workspace_symbol_A>/lib/LibTypes.mli 0:0 0:15",
190-
"x 12 file://<workspace_symbol_A>/lib/vendored_lib.ml 0:0 0:9",
190+
"x 12 file://<workspace_symbol_A>/vendor/vendored_lib.ml 0:0 0:9",
191191
"workspace_B 12 file://<workspace_symbol_B>/main.ml 0:0 0:31",
192192
]
193193
`);

0 commit comments

Comments
 (0)