Skip to content

Commit ddc23b0

Browse files
authored
Iterate objects (#1065)
* iterate objects * changelog
1 parent 85a72dc commit ddc23b0

File tree

4 files changed

+51
-0
lines changed

4 files changed

+51
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#### :bug: Bug fix
2020

2121
- Fix bug where type args stopped working in some completions when passed through inline records. https://github.com/rescript-lang/rescript-vscode/pull/1064
22+
- Fix bug where objects weren't actually iterated on, making completions inside of them not work. https://github.com/rescript-lang/rescript-vscode/pull/1065
2223

2324
## 1.60.0
2425

analysis/src/CompletionFrontEnd.ml

+2
Original file line numberDiff line numberDiff line change
@@ -1106,6 +1106,8 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor
11061106
if expr.pexp_loc |> Loc.hasPos ~pos:posNoWhite && !result = None then (
11071107
setFound ();
11081108
match expr.pexp_desc with
1109+
| Pexp_extension ({txt = "obj"}, PStr [str_item]) ->
1110+
Ast_iterator.default_iterator.structure_item iterator str_item
11091111
| Pexp_extension ({txt}, _) -> setResult (CextensionNode txt)
11101112
| Pexp_constant _ -> setResult Cnone
11111113
| Pexp_ident lid ->
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
let x = Some(true)
2+
3+
let _ff = {
4+
"one": switch x {
5+
| Some(true) => "hello"
6+
// |
7+
// ^com
8+
| _ => ""
9+
},
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Complete src/CompletionObjects.res 5:7
2+
posCursor:[5:7] posNoWhite:[5:5] Found expr:[2:10->9:1]
3+
posCursor:[5:7] posNoWhite:[5:5] Found expr:[2:10->9:1]
4+
posCursor:[5:7] posNoWhite:[5:5] Found pattern:__ghost__[0:-1->7:5]
5+
posCursor:[5:7] posNoWhite:[5:5] Found pattern:__ghost__[0:-1->7:5]
6+
Completable: Cpattern Value[x]
7+
Package opens Pervasives.JsxModules.place holder
8+
Resolved opens 1 pervasives
9+
ContextPath Value[x]
10+
Path x
11+
[{
12+
"label": "None",
13+
"kind": 12,
14+
"tags": [],
15+
"detail": "bool",
16+
"documentation": null
17+
}, {
18+
"label": "Some(_)",
19+
"kind": 12,
20+
"tags": [],
21+
"detail": "bool",
22+
"documentation": null,
23+
"insertText": "Some(${1:_})",
24+
"insertTextFormat": 2
25+
}, {
26+
"label": "Some(true)",
27+
"kind": 4,
28+
"tags": [],
29+
"detail": "bool",
30+
"documentation": null
31+
}, {
32+
"label": "Some(false)",
33+
"kind": 4,
34+
"tags": [],
35+
"detail": "bool",
36+
"documentation": null
37+
}]
38+

0 commit comments

Comments
 (0)