Skip to content

Commit

Permalink
support intellisense default value
Browse files Browse the repository at this point in the history
  • Loading branch information
928PJY committed Aug 29, 2018
1 parent dc3310a commit 6e69a35
Showing 1 changed file with 35 additions and 30 deletions.
65 changes: 35 additions & 30 deletions src/languageservice/services/yamlCompletion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -528,37 +528,42 @@ export class YAMLCompletion {
let value;
let nValueProposals = 0;
if (propertySchema) {
if (nValueProposals === 0) {
var type = Array.isArray(propertySchema.type) ? propertySchema.type[0] : propertySchema.type;
if (!type) {
if (propertySchema.properties) {
type = 'object';
} else if (propertySchema.items) {
type = 'array';
if (propertySchema.default !== undefined) {
value = ` \${1:${propertySchema.default}}`
}
else {
if (nValueProposals === 0) {
var type = Array.isArray(propertySchema.type) ? propertySchema.type[0] : propertySchema.type;
if (!type) {
if (propertySchema.properties) {
type = 'object';
} else if (propertySchema.items) {
type = 'array';
}
}
switch (type) {
case 'boolean':
value = ' $1';
break;
case 'string':
value = ' $1';
break;
case 'object':
value = '\n\t';
break;
case 'array':
value = '\n\t- ';
break;
case 'number':
case 'integer':
value = ' ${1:0}';
break;
case 'null':
value = ' ${1:null}';
break;
default:
return propertyText;
}
}
switch (type) {
case 'boolean':
value = ' $1';
break;
case 'string':
value = ' $1';
break;
case 'object':
value = '\n\t';
break;
case 'array':
value = '\n\t- ';
break;
case 'number':
case 'integer':
value = ' ${1:0}';
break;
case 'null':
value = ' ${1:null}';
break;
default:
return propertyText;
}
}
}
Expand Down

0 comments on commit 6e69a35

Please sign in to comment.