Skip to content
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

Don't wrap in array and object completions #29

Merged
merged 3 commits into from
Oct 22, 2018
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
10 changes: 5 additions & 5 deletions src/services/jsonCompletion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -664,9 +664,9 @@ export class JSONCompletion {
private getInsertTextForValue(value: any, separatorAfter: string): string {
var text = JSON.stringify(value, null, '\t');
if (text === '{}') {
return '{\n\t$1\n}' + separatorAfter;
return '{$1}' + separatorAfter;
} else if (text === '[]') {
return '[\n\t$1\n]' + separatorAfter;
return '[$1]' + separatorAfter;
}
return this.getInsertTextForPlainText(text + separatorAfter);
}
Expand Down Expand Up @@ -793,10 +793,10 @@ export class JSONCompletion {
value = '"$1"';
break;
case 'object':
value = '{\n\t$1\n}';
value = '{$1}';
break;
case 'array':
value = '[\n\t$1\n]';
value = '[$1]';
break;
case 'number':
case 'integer':
Expand Down Expand Up @@ -887,4 +887,4 @@ export class JSONCompletion {
return this.supportsMarkdown;
}

}
}
10 changes: 5 additions & 5 deletions src/test/completion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ suite('JSON Completion', () => {
await testCompletionsFor('[ { "data": { "key": 1, "data": true } }, { "data": |', null, {
count: 3,
items: [
{ label: '{}', resultText: '[ { "data": { "key": 1, "data": true } }, { "data": {\n\t$1\n}' },
{ label: '{}', resultText: '[ { "data": { "key": 1, "data": true } }, { "data": {$1}' },
{ label: 'true', resultText: '[ { "data": { "key": 1, "data": true } }, { "data": true' },
{ label: 'false', resultText: '[ { "data": { "key": 1, "data": true } }, { "data": false' }
]
Expand Down Expand Up @@ -864,7 +864,7 @@ suite('JSON Completion', () => {
});
await testCompletionsFor('|', schema2, {
items: [
{ label: '{}', resultText: '{\n\t$1\n}' },
{ label: '{}', resultText: '{$1}' },
{ label: 'def1', documentation: 'def1Desc', resultText: '{\n\t"hello": "${1:world}"\n}' },
{ label: '{"hello":["world"]}', resultText: '{\n\t"${1:hello}": [\n\t\t"${2:world}"\n\t]\n}' }
]
Expand Down Expand Up @@ -1143,8 +1143,8 @@ suite('JSON Completion', () => {

await testCompletionsFor('{ |', schema, {
items: [
{ label: 'object', resultText: '{ "object": {\n\t$1\n}' },
{ label: 'array', resultText: '{ "array": [\n\t$1\n]' },
{ label: 'object', resultText: '{ "object": {$1}' },
{ label: 'array', resultText: '{ "array": [$1]' },
{ label: 'string', resultText: '{ "string": "$1"' },
{ label: 'boolean', resultText: '{ "boolean": $1' },
{ label: 'oneEnum', resultText: '{ "oneEnum": "${1:foo}"' },
Expand All @@ -1157,4 +1157,4 @@ suite('JSON Completion', () => {
]
});
});
});
});