Skip to content

Fix issue with autocomplete then punned props are used in JSX. #316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 23, 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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
- Fix issue in JSX autocomplete when the component is declared external.
- Fix jump-to-definition for uncurried calls.
- Fix issue where values for autocomplete were pulled from implementations instead of interfaces.
- Fix issue with autocomplete then punned props are used in JSX. E.g. `<M foo ...>`.
- Add autocompletion for object access of the form foo["bar"].

## 1.1.3
Expand Down
6 changes: 3 additions & 3 deletions analysis/src/PartialParser.ml
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,16 @@ let findJsxContext text offset =
match ident.[0] with
| ('a' .. 'z' | 'A' .. 'Z') when i1 >= 1 && text.[i1 - 1] = '<' ->
Some (ident, identsSeen)
| _ -> beforeIdent identsSeen (i1 - 1)
| _ -> beforeIdent ~ident identsSeen (i1 - 1)
else None
else None
and beforeIdent identsSeen i =
and beforeIdent ~ident identsSeen i =
let i = skipWhite text i in
if i > 0 then
match text.[i] with
| '?' -> fromEquals identsSeen (i - 1)
| '=' -> fromEquals identsSeen i
| _ -> loop identsSeen (i - 1)
| _ -> (* punning *) loop (ident :: identsSeen) i
else None
and beforeParen identsSeen i =
let i = skipWhite text i in
Expand Down
2 changes: 2 additions & 0 deletions analysis/tests/src/Jsx.res
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ module Ext = {
let _ = (Ext.make, Ext.makeProps)

//^com <Ext al

//^com <M first
29 changes: 22 additions & 7 deletions analysis/tests/src/expected/Jsx.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,7 @@ Complete tests/src/Jsx.res 30:2
}]

Complete tests/src/Jsx.res 32:2
[{
"label": "key",
"kind": 4,
"tags": [],
"detail": "string",
"documentation": null
}]
[]

Complete tests/src/Jsx.res 34:2
[{
Expand Down Expand Up @@ -196,3 +190,24 @@ Complete tests/src/Jsx.res 52:2
"documentation": null
}]

Complete tests/src/Jsx.res 54:2
[{
"label": "second",
"kind": 4,
"tags": [],
"detail": "option<string>",
"documentation": null
}, {
"label": "fun",
"kind": 4,
"tags": [],
"detail": "option<string>",
"documentation": null
}, {
"label": "key",
"kind": 4,
"tags": [],
"detail": "string",
"documentation": null
}]