diff --git a/CHANGELOG.md b/CHANGELOG.md index 376172964..40ca6a0b3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,10 @@ - Add support for syntax highlighting in `%raw` and `%ffi` extension points. https://github.com/rescript-lang/rescript-vscode/pull/774 +#### :bug: Bug Fix + +- Fix invalid range for `definition`. https://github.com/rescript-lang/rescript-vscode/pull/781 + ## 1.18.0 #### :rocket: New Feature diff --git a/analysis/src/Commands.ml b/analysis/src/Commands.ml index 4341c4f82..65fe589c5 100644 --- a/analysis/src/Commands.ml +++ b/analysis/src/Commands.ml @@ -94,7 +94,7 @@ let definition ~path ~pos ~debug = | Some locItem -> ( match References.definitionForLocItem ~full locItem with | None -> None - | Some (uri, loc) -> + | Some (uri, loc) when not loc.loc_ghost -> let isInterface = full.file.uri |> Uri.isInterface in let posIsZero {Lexing.pos_lnum; pos_bol; pos_cnum} = (* range is zero *) @@ -113,7 +113,7 @@ let definition ~path ~pos ~debug = else Some {Protocol.uri = Uri.toString uri; range = Utils.cmtLocToRange loc} - )) + | Some _ -> None)) in print_endline (match locationOpt with