diff --git a/CHANGELOG.md b/CHANGELOG.md index 5234be8b7d..f49ef00fa8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - Editor: Fix issue where pipe completions would not trigger with generic type arguments. https://github.com/rescript-lang/rescript/pull/7231 - Fix leftover assert false in code for `null != undefined`. https://github.com/rescript-lang/rescript/pull/7232 +- Editor: Fix issue where completions would not show up inside of object bodies. https://github.com/rescript-lang/rescript/pull/7230 # 12.0.0-alpha.7 diff --git a/analysis/src/CompletionFrontEnd.ml b/analysis/src/CompletionFrontEnd.ml index e22b24b891..ceebf92274 100644 --- a/analysis/src/CompletionFrontEnd.ml +++ b/analysis/src/CompletionFrontEnd.ml @@ -1107,6 +1107,8 @@ let completionWithParser1 ~currentFile ~debug ~offset ~path ~posCursor if expr.pexp_loc |> Loc.hasPos ~pos:posNoWhite && !result = None then ( setFound (); match expr.pexp_desc with + | Pexp_extension ({txt = "obj"}, PStr [str_item]) -> + Ast_iterator.default_iterator.structure_item iterator str_item | Pexp_extension ({txt}, _) -> setResult (CextensionNode txt) | Pexp_constant _ -> setResult Cnone | Pexp_ident lid -> diff --git a/tests/analysis_tests/tests/src/CompletionObjects.res b/tests/analysis_tests/tests/src/CompletionObjects.res new file mode 100644 index 0000000000..6de39bd1a2 --- /dev/null +++ b/tests/analysis_tests/tests/src/CompletionObjects.res @@ -0,0 +1,10 @@ +let x = Some(true) + +let _ff = { + "one": switch x { + | Some(true) => "hello" + // | + // ^com + | _ => "" + }, +} diff --git a/tests/analysis_tests/tests/src/expected/CompletionObjects.res.txt b/tests/analysis_tests/tests/src/expected/CompletionObjects.res.txt new file mode 100644 index 0000000000..f9a78b5378 --- /dev/null +++ b/tests/analysis_tests/tests/src/expected/CompletionObjects.res.txt @@ -0,0 +1,37 @@ +Complete src/CompletionObjects.res 5:7 +posCursor:[5:7] posNoWhite:[5:5] Found expr:[2:10->9:1] +posCursor:[5:7] posNoWhite:[5:5] Found expr:[2:10->9:1] +posCursor:[5:7] posNoWhite:[5:5] Found pattern:__ghost__[0:-1->7:5] +posCursor:[5:7] posNoWhite:[5:5] Found pattern:__ghost__[0:-1->7:5] +Completable: Cpattern Value[x] +Package opens Pervasives.JsxModules.place holder +ContextPath Value[x] +Path x +[{ + "label": "None", + "kind": 12, + "tags": [], + "detail": "bool", + "documentation": null + }, { + "label": "Some(_)", + "kind": 12, + "tags": [], + "detail": "bool", + "documentation": null, + "insertText": "Some(${1:_})", + "insertTextFormat": 2 + }, { + "label": "Some(true)", + "kind": 4, + "tags": [], + "detail": "bool", + "documentation": null + }, { + "label": "Some(false)", + "kind": 4, + "tags": [], + "detail": "bool", + "documentation": null + }] +