Skip to content

Commit d77ca15

Browse files
authored
Extend quoting functionality to include polyvariant keywords (#877)
* extend quoting functionality to include polyvariant keywords * update CHANGELOG.md
1 parent 0d8fbc3 commit d77ca15

File tree

4 files changed

+4
-3
lines changed

4 files changed

+4
-3
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#### :bug: Bug Fix
1616

1717
- Fix so that you don't need a leading `#` to complete for polyvariant constructors. https://github.com/rescript-lang/rescript-vscode/pull/874
18+
- Print keyword polyvariant constructors with quotes when doing completions. https://github.com/rescript-lang/rescript-vscode/pull/877
1819

1920
## 1.30.0
2021

analysis/src/Utils.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -259,4 +259,4 @@ let printMaybeExoticIdent ?(allowUident = false) txt =
259259
| 'A' .. 'Z' | 'a' .. 'z' | '0' .. '9' | '\'' | '_' -> loop (i + 1)
260260
| _ -> "\"" ^ txt ^ "\""
261261
in
262-
loop 0
262+
if Res_token.isKeywordTxt txt then "\"" ^ txt ^ "\"" else loop 0

analysis/tests/src/ExhaustiveSwitch.res

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
type someVariant = One | Two | Three(option<bool>)
2-
type somePolyVariant = [#one | #two | #three(option<bool>) | #"exotic ident"]
2+
type somePolyVariant = [#one | #two | #three(option<bool>) | #"exotic ident" | #"switch"]
33

44
let withSomeVariant = One
55
let withSomePoly: somePolyVariant = #one

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Path withSomePol
4242
"detail": "insert exhaustive switch for value",
4343
"documentation": null,
4444
"filterText": "withSomePoly",
45-
"insertText": "withSomePoly {\n | #one => ${1:failwith(\"todo\")}\n | #three(_) => ${2:failwith(\"todo\")}\n | #two => ${3:failwith(\"todo\")}\n | #\"exotic ident\" => ${4:failwith(\"todo\")}\n }",
45+
"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 }",
4646
"insertTextFormat": 2
4747
}]
4848

0 commit comments

Comments
 (0)