Skip to content

Commit

Permalink
Merge pull request #29 from FloEdelmann/patch-1
Browse files Browse the repository at this point in the history
Don't wrap in array and object completions
  • Loading branch information
aeschli authored Oct 22, 2018
2 parents 29c1edd + 7ca7a1e commit 51d84b0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
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', () => {
]
});
});
});
});

0 comments on commit 51d84b0

Please sign in to comment.