Skip to content

Editor: Fix issue where type arg ctx was not passed along properly #7227

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
Jan 5, 2025
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@

# 12.0.0-alpha.7 (Unreleased)

#### :bug: Bug fix

- Editor: Fix issue where completions would stop working in some scenarios with inline records. https://github.com/rescript-lang/rescript/pull/7227

#### :nail_care: Polish

- Add all standard CSS properties to `JsxDOMStyle`. https://github.com/rescript-lang/rescript/pull/7205
Expand Down
7 changes: 4 additions & 3 deletions analysis/src/TypeUtils.ml
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ let rec resolveNested ?typeArgContext ~env ~full ~nested ?ctx
Toption (env, ExtractedType typ) ) ->
if Debug.verbose () then
print_endline "[nested]--> moving into option Some";
typ |> resolveNested ~env ~full ~nested
typ |> resolveNested ?typeArgContext ~env ~full ~nested
| ( NVariantPayload {constructorName = "Some"; itemNum = 0},
Toption (env, TypeExpr typ) ) ->
if Debug.verbose () then
Expand Down Expand Up @@ -706,7 +706,8 @@ let rec resolveNested ?typeArgContext ~env ~full ~nested ?ctx
| Some {args = InlineRecord fields} when itemNum = 0 ->
if Debug.verbose () then
print_endline "[nested]--> found constructor (inline record)";
TinlineRecord {env; fields} |> resolveNested ~env ~full ~nested
TinlineRecord {env; fields}
|> resolveNested ?typeArgContext ~env ~full ~nested
| _ -> None)
| ( NPolyvariantPayload {constructorName; itemNum},
Tpolyvariant {env; constructors} ) -> (
Expand All @@ -725,7 +726,7 @@ let rec resolveNested ?typeArgContext ~env ~full ~nested ?ctx
|> Utils.Option.flatMap (fun (typ, typeArgContext) ->
typ |> resolveNested ?typeArgContext ~env ~full ~nested)))
| NArray, Tarray (env, ExtractedType typ) ->
typ |> resolveNested ~env ~full ~nested
typ |> resolveNested ?typeArgContext ~env ~full ~nested
| NArray, Tarray (env, TypeExpr typ) ->
typ
|> extractType ~env ~package:full.package
Expand Down
1 change: 1 addition & 0 deletions tests/analysis_tests/tests/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tests/analysis_tests/tests/src/Support.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module CatchResult = {
@tag("ok")
type t<'value> = | @as(true) Ok({value: 'value}) | @as(false) Error({errors: array<string>})
}
9 changes: 9 additions & 0 deletions tests/analysis_tests/tests/src/TypeArgCtx.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
type someTyp = {test: bool}
let catchResult = Support.CatchResult.Ok({
value: {
test: true,
},
})

// switch catchResult { | Ok({value: }) => ()
// ^com
10 changes: 10 additions & 0 deletions tests/analysis_tests/tests/src/expected/Completion.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2096,6 +2096,16 @@ Path T
"modulePath": "Type",
"filePath": "src/Completion.res"
}
}, {
"label": "TypeArgCtx",
"kind": 9,
"tags": [],
"detail": "module TypeArgCtx",
"documentation": null,
"data": {
"modulePath": "TypeArgCtx",
"filePath": "src/Completion.res"
}
}, {
"label": "TypeAtPosCompletion",
"kind": 9,
Expand Down
10 changes: 10 additions & 0 deletions tests/analysis_tests/tests/src/expected/CompletionJsxProps.res.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,16 @@ Path CompletionSupport.TestComponent.make
"modulePath": "Type",
"filePath": "src/CompletionJsxProps.res"
}
}, {
"label": "TypeArgCtx",
"kind": 9,
"tags": [],
"detail": "module TypeArgCtx",
"documentation": null,
"data": {
"modulePath": "TypeArgCtx",
"filePath": "src/CompletionJsxProps.res"
}
}, {
"label": "TypeAtPosCompletion",
"kind": 9,
Expand Down
Empty file.
19 changes: 19 additions & 0 deletions tests/analysis_tests/tests/src/expected/TypeArgCtx.res.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Complete src/TypeArgCtx.res 7:36
posCursor:[7:36] posNoWhite:[7:35] Found pattern:[7:26->7:39]
Ppat_construct Ok:[7:26->7:28]
posCursor:[7:36] posNoWhite:[7:35] Found pattern:[7:29->7:38]
Completable: Cpattern Value[catchResult]->variantPayload::Ok($0), recordField(value)
Package opens Pervasives.JsxModules.place holder
ContextPath Value[catchResult]
Path catchResult
[{
"label": "{}",
"kind": 22,
"tags": [],
"detail": "someTyp",
"documentation": {"kind": "markdown", "value": "```rescript\ntype someTyp = {test: bool}\n```"},
"sortText": "A",
"insertText": "{$0}",
"insertTextFormat": 2
}]

Loading