Skip to content

Commit 20e20a4

Browse files
authored
Fix issue with autocomplete then punned props are used in JSX. (#316)
* Fix issue with autocomplete then punned props are used in JSX. E.g. `<M foo ...>`. * Correctly count the seen ID in case of punning.
1 parent e974170 commit 20e20a4

File tree

4 files changed

+28
-10
lines changed

4 files changed

+28
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
- Fix issue in JSX autocomplete when the component is declared external.
33
- Fix jump-to-definition for uncurried calls.
44
- Fix issue where values for autocomplete were pulled from implementations instead of interfaces.
5+
- Fix issue with autocomplete then punned props are used in JSX. E.g. `<M foo ...>`.
56
- Add autocompletion for object access of the form foo["bar"].
67

78
## 1.1.3

analysis/src/PartialParser.ml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,16 +143,16 @@ let findJsxContext text offset =
143143
match ident.[0] with
144144
| ('a' .. 'z' | 'A' .. 'Z') when i1 >= 1 && text.[i1 - 1] = '<' ->
145145
Some (ident, identsSeen)
146-
| _ -> beforeIdent identsSeen (i1 - 1)
146+
| _ -> beforeIdent ~ident identsSeen (i1 - 1)
147147
else None
148148
else None
149-
and beforeIdent identsSeen i =
149+
and beforeIdent ~ident identsSeen i =
150150
let i = skipWhite text i in
151151
if i > 0 then
152152
match text.[i] with
153153
| '?' -> fromEquals identsSeen (i - 1)
154154
| '=' -> fromEquals identsSeen i
155-
| _ -> loop identsSeen (i - 1)
155+
| _ -> (* punning *) loop (ident :: identsSeen) i
156156
else None
157157
and beforeParen identsSeen i =
158158
let i = skipWhite text i in

analysis/tests/src/Jsx.res

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,5 @@ module Ext = {
5252
let _ = (Ext.make, Ext.makeProps)
5353

5454
//^com <Ext al
55+
56+
//^com <M first

analysis/tests/src/expected/Jsx.res.txt

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,7 @@ Complete tests/src/Jsx.res 30:2
134134
}]
135135

136136
Complete tests/src/Jsx.res 32:2
137-
[{
138-
"label": "key",
139-
"kind": 4,
140-
"tags": [],
141-
"detail": "string",
142-
"documentation": null
143-
}]
137+
[]
144138

145139
Complete tests/src/Jsx.res 34:2
146140
[{
@@ -196,3 +190,24 @@ Complete tests/src/Jsx.res 52:2
196190
"documentation": null
197191
}]
198192

193+
Complete tests/src/Jsx.res 54:2
194+
[{
195+
"label": "second",
196+
"kind": 4,
197+
"tags": [],
198+
"detail": "option<string>",
199+
"documentation": null
200+
}, {
201+
"label": "fun",
202+
"kind": 4,
203+
"tags": [],
204+
"detail": "option<string>",
205+
"documentation": null
206+
}, {
207+
"label": "key",
208+
"kind": 4,
209+
"tags": [],
210+
"detail": "string",
211+
"documentation": null
212+
}]
213+

0 commit comments

Comments
 (0)