Skip to content
This repository was archived by the owner on Apr 24, 2021. It is now read-only.

Fix hover on labels in component functions with compiler version 9.1. #133

Merged
merged 2 commits into from
Apr 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Add autocomplete for props in JSX components.
- Autocomplete: fix issue where `->` autocomplete was overruling `.`. See https://github.com/rescript-lang/rescript-editor-support/issues/99.
- Add pipe autocomplete for builtin list, array, string, option types. And for string and array literals.
- Fix hover on labels in component functions with compiler version 9.1.

## Release 1.0.6 of rescript-vscode
This [commit](https://github.com/rescript-lang/rescript-editor-support/commit/03ee0d97b250474028d4fb08eac81ddb21ccb082) is vendored in [rescript-vscode 1.0.6](https://github.com/rescript-lang/rescript-vscode/releases/tag/1.0.6).
Expand Down
6 changes: 6 additions & 0 deletions src/References.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,17 @@ let locsForPos ~extra pos =

let locForPos ~extra pos =
match locsForPos ~extra pos with
| [(loc1, Typed (_, LocalReference _)); ((loc3, _) as l3)] when loc1 = loc3 ->
(* JSX and compiler combined: *)
(* ~x becomes Props#x *)
(* heuristic for: [Props, x], give loc of `x` *)
Some l3
| [
(loc1, Typed (_, LocalReference _));
(loc2, Typed (_, GlobalReference ("Js_OO", Tip "unsafe_downgrade", _)));
((loc3, _) as l3);
]
(* For older compiler 9.0 or earlier *)
when loc1 = loc2 && loc2 = loc3 ->
(* JSX and compiler combined: *)
(* ~x becomes Js_OO.unsafe_downgrade(Props)#x *)
Expand Down
2 changes: 1 addition & 1 deletion test/src/expected/Hover.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ Hover src/Hover.res 33:4
{"contents": "```rescript\nunit => int\n```\n\nDoc comment for functionWithTypeAnnotation"}

Hover src/Hover.res 37:13
null
{"contents": "```rescript\nstring\n```"}