From 9aa86e853309543b216f7344d7ee5a73b3bebac3 Mon Sep 17 00:00:00 2001 From: Mathieu HATON Date: Tue, 19 Dec 2023 12:25:23 +0100 Subject: [PATCH 1/2] extend quoting functionality to include polyvariant keywords --- analysis/src/Utils.ml | 2 +- analysis/tests/src/ExhaustiveSwitch.res | 2 +- analysis/tests/src/expected/ExhaustiveSwitch.res.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/analysis/src/Utils.ml b/analysis/src/Utils.ml index 773389c2b..394af3adc 100644 --- a/analysis/src/Utils.ml +++ b/analysis/src/Utils.ml @@ -259,4 +259,4 @@ let printMaybeExoticIdent ?(allowUident = false) txt = | 'A' .. 'Z' | 'a' .. 'z' | '0' .. '9' | '\'' | '_' -> loop (i + 1) | _ -> "\"" ^ txt ^ "\"" in - loop 0 + if Res_token.isKeywordTxt txt then "\"" ^ txt ^ "\"" else loop 0 diff --git a/analysis/tests/src/ExhaustiveSwitch.res b/analysis/tests/src/ExhaustiveSwitch.res index 5816aa635..dd83f1ad5 100644 --- a/analysis/tests/src/ExhaustiveSwitch.res +++ b/analysis/tests/src/ExhaustiveSwitch.res @@ -1,5 +1,5 @@ type someVariant = One | Two | Three(option) -type somePolyVariant = [#one | #two | #three(option) | #"exotic ident"] +type somePolyVariant = [#one | #two | #three(option) | #"exotic ident" | #"switch"] let withSomeVariant = One let withSomePoly: somePolyVariant = #one diff --git a/analysis/tests/src/expected/ExhaustiveSwitch.res.txt b/analysis/tests/src/expected/ExhaustiveSwitch.res.txt index 37a1c6973..71285318b 100644 --- a/analysis/tests/src/expected/ExhaustiveSwitch.res.txt +++ b/analysis/tests/src/expected/ExhaustiveSwitch.res.txt @@ -42,7 +42,7 @@ Path withSomePol "detail": "insert exhaustive switch for value", "documentation": null, "filterText": "withSomePoly", - "insertText": "withSomePoly {\n | #one => ${1:failwith(\"todo\")}\n | #three(_) => ${2:failwith(\"todo\")}\n | #two => ${3:failwith(\"todo\")}\n | #\"exotic ident\" => ${4:failwith(\"todo\")}\n }", + "insertText": "withSomePoly {\n | #\"switch\" => ${1:failwith(\"todo\")}\n | #one => ${2:failwith(\"todo\")}\n | #three(_) => ${3:failwith(\"todo\")}\n | #two => ${4:failwith(\"todo\")}\n | #\"exotic ident\" => ${5:failwith(\"todo\")}\n }", "insertTextFormat": 2 }] From 22ea4fe40532f69b995579de605ff869021b093b Mon Sep 17 00:00:00 2001 From: Mathieu HATON Date: Tue, 19 Dec 2023 14:26:35 +0100 Subject: [PATCH 2/2] update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3278948d..64915f24c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ #### :bug: Bug Fix - Fix so that you don't need a leading `#` to complete for polyvariant constructors. https://github.com/rescript-lang/rescript-vscode/pull/874 +- Print keyword polyvariant constructors with quotes when doing completions. https://github.com/rescript-lang/rescript-vscode/pull/877 ## 1.30.0