-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.js
More file actions
261 lines (238 loc) · 6.89 KB
/
test.js
File metadata and controls
261 lines (238 loc) · 6.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
import {parse} from './parse.js'
import {stringify} from './stringify.js'
import {astToJs} from './astToJs.js'
import {unparse} from './unparse.js'
import {astLikeJson} from './astLikeJson.js'
import {astToConfig} from './astToConfig.js'
import { parseHeredoc } from './parseHeredoc.js'
import { astToJs2 } from './astToJs2.js'
const input = `
editor.quickSuggestions [
other [true]
comments [false]
strings [false]
]
terminal.integrated.wordSeparators [ ()\`[\`]{}',"\`\`─‘’]
terminal.integrated.scrollback [1000]
remote.extensionKind [
pub.name [[ui]]
]
git.checkoutType [[local] [remote] [tags]]
git.defaultCloneDirectory [null]
`
const expectedDecoded = {
"subvalues": [
{
"prefix": "\neditor.quickSuggestions ",
"value": {
"subvalues": [
{
"prefix": "\n other ",
"value": {
"subvalues": [],
"suffix": "true"
}
},
{
"prefix": "\n comments ",
"value": {
"subvalues": [],
"suffix": "false"
}
},
{
"prefix": "\n strings ",
"value": {
"subvalues": [],
"suffix": "false"
}
}
],
"suffix": "\n"
}
},
{
"prefix": "\nterminal.integrated.wordSeparators ",
"value": {
"subvalues": [],
"suffix": " ()[]{}',\"`─‘’"
}
},
{
"prefix": "\nterminal.integrated.scrollback ",
"value": {
"subvalues": [],
"suffix": "1000"
}
},
{
"prefix": "\nremote.extensionKind ",
"value": {
"subvalues": [
{
"prefix": "\n pub.name ",
"value": {
"subvalues": [
{
"prefix": "",
"value": {
"subvalues": [],
"suffix": "ui"
}
}
],
"suffix": ""
}
}
],
"suffix": "\n"
}
},
{
"prefix": "\ngit.checkoutType ",
"value": {
"subvalues": [
{
"prefix": "",
"value": {
"subvalues": [],
"suffix": "local"
}
},
{
"prefix": " ",
"value": {
"subvalues": [],
"suffix": "remote"
}
},
{
"prefix": " ",
"value": {
"subvalues": [],
"suffix": "tags"
}
}
],
"suffix": ""
}
},
{
"prefix": "\ngit.defaultCloneDirectory ",
"value": {
"subvalues": [],
"suffix": "null"
}
}
],
"suffix": "\n",
"open": "[",
"close": "]",
"escape": "`"
}
const expectedConverted = {
"editor.quickSuggestions": {
"other": true,
"comments": false,
"strings": false
},
"terminal.integrated.wordSeparators": " ()[]{}',\"`─‘’",
"terminal.integrated.scrollback": 1000,
"remote.extensionKind": {
"pub.name": [
"ui"
]
},
"git.checkoutType": [
"local",
"remote",
"tags"
],
"git.defaultCloneDirectory": null
}
const expectedEncoded = `editor.quickSuggestions[other[true]comments[false]strings[false]]terminal.integrated.wordSeparators[ ()\`[\`]{}',"\`\`─‘’]terminal.integrated.scrollback[1000]remote.extensionKind[pub.name[[ui]]]git.checkoutType[[local][remote][tags]]git.defaultCloneDirectory[null]`
const decoded = parse(input)
const converted = astToJs(decoded)
const encoded = stringify(converted)
const stringified = unparse(decoded)
console.assert(JSON.stringify(decoded) === JSON.stringify(expectedDecoded), decoded)
console.assert(JSON.stringify(converted) === JSON.stringify(expectedConverted), converted)
console.assert(encoded === expectedEncoded, encoded)
console.assert(input === stringified, stringified)
console.assert(JSON.stringify(astLikeJson(parse(`
{
Controls whether suggestions should automatically show up while typing.
(editor.quickSuggestions)({
(other)(true)
(comments)(false)
(strings)(false)
})
A string containing all characters to be considered word separators by the double click to select word feature.
(terminal.integrated.wordSeparators)(" \\(\\)[]{}',"\`─‘’)
Controls the maximum amount of lines the terminal keeps in its buffer.
(terminal.integrated.scrollback)(1000)
Override the kind of an extension. \`ui\` extensions are installed and run on the local machine while \`workspace\` extensions are run on the remote. By overriding an extension's default kind using this setting, you specify if that extension should be installed and enabled locally or remotely.
(remote.extensionKind)({
(pub.name)([("ui)])
})
Controls what type of git refs are listed when running \`Checkout to...\`.
- local: Local branches
- tags: Tags
- remote: Remote branches
(git.checkoutType)([("local)("remote)("tags)])
The default location to clone a git repository.
(git.defaultCloneDirectory)(null)
}
`, {open: '(', close: ')', escape: '\\'}))) === JSON.stringify(expectedConverted))
console.assert(JSON.stringify(astToConfig(parse(`
-editor.quickSuggestions
Controls whether suggestions should automatically show up while typing.
[
other [true]
comments [false]
strings [false]
]
-terminal.integrated.wordSeparators
A string containing all characters to be considered word separators by the double click to select word feature.
[ ()\`[\`]{}',"\`\`─‘’]
terminal.integrated.scrollback
Controls the maximum amount of lines the terminal keeps in its buffer.
[1000]
remote.extensionKind
Override the kind of an extension. 'ui' extensions are installed and run on the local machine while 'workspace' extensions are run on the remote. By overriding an extension's default kind using this setting, you specify if that extension should be installed and enabled locally or remotely.
[
pub.name [[ui]]
]
git.checkoutType
Controls what type of git refs are listed when running 'Checkout to...'.
- local: Local branches
- tags: Tags
- remote: Remote branches
[[local] [remote] [tags]]
git.defaultCloneDirectory
The default location to clone a git repository.
[null]
`))) === `{"terminal.integrated.scrollback":1000,"remote.extensionKind":{"pub.name":["ui"]},"git.checkoutType":["local","remote","tags"],"git.defaultCloneDirectory":null}`)
console.log(JSON.stringify(parseHeredoc(`
key1 [value]
key2 [\`~end
multiline
value with unescaped ][\`
]]][[[[][]]]]\`\`\`\`
end
]
`), null, 2))
console.log(astToJs2(parse(`:
editor.quickSuggestions [:
other [t]
comments [f]
strings [f]
]
terminal.integrated.wordSeparators [' ()\`[\`]{}',"\`\`─‘’]
terminal.integrated.scrollback [1000]
remote.extensionKind [:
pub.name [,['ui]]
]
git.checkoutType [,['local] ['remote] ['tags]]
git.defaultCloneDirectory [n]
`)))