Skip to content

Commit d04de8a

Browse files
committed
Fix issue with JSX autocompletion not working after foo=#variant.
Fixes #313
1 parent 51de935 commit d04de8a

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- Fix issue where values for autocomplete were pulled from implementations instead of interfaces.
55
- Add autocompletion for object access of the form foo["bar"].
66
- Fix issue with autocomplete then punned props are used in JSX. E.g. `<M foo ...>`.
7+
- Fix issue with JSX autocompletion not working after `foo=#variant`.
78

89
## 1.1.3
910

analysis/src/PartialParser.ml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ let skipOptVariantExtension text i =
107107
Find JSX context ctx for component M to autocomplete id (already parsed) as a prop.
108108
ctx ::= <M args id
109109
arg ::= id | id = [?] atomicExpr
110-
atomicExpr ::= id | "abc" | 'a' | 42 | `...` | optVariant {...} | optVariant (...) | <...> | [...]
110+
atomicExpr ::= id | #id | "abc" | 'a' | 42 | `...` | optVariant {...} | optVariant (...) | <...> | [...]
111111
optVariant ::= id | #id | %id | _nothing_
112112
*)
113113
let findJsxContext text offset =
@@ -143,7 +143,10 @@ 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 ~ident identsSeen (i1 - 1)
146+
| _ ->
147+
if i1 >= 1 && text.[i1 - 1] = '#' then
148+
beforeValue identsSeen (i1 - 2)
149+
else beforeIdent ~ident identsSeen (i1 - 1)
147150
else None
148151
else None
149152
and beforeIdent ~ident identsSeen i =

analysis/tests/src/Jsx.res

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,7 @@ let _ = (Ext.make, Ext.makeProps)
5454
//^com <Ext al
5555

5656
//^com <M first
57+
58+
//^com <M first=#a k
59+
60+
//^com <M first = ? #a k

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,21 @@ Complete tests/src/Jsx.res 54:2
211211
"documentation": null
212212
}]
213213

214+
Complete tests/src/Jsx.res 56:2
215+
[{
216+
"label": "key",
217+
"kind": 4,
218+
"tags": [],
219+
"detail": "string",
220+
"documentation": null
221+
}]
222+
223+
Complete tests/src/Jsx.res 58:2
224+
[{
225+
"label": "key",
226+
"kind": 4,
227+
"tags": [],
228+
"detail": "string",
229+
"documentation": null
230+
}]
231+

0 commit comments

Comments
 (0)