Skip to content
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
8 changes: 4 additions & 4 deletions src/languageservice/services/yamlCompletion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -684,19 +684,19 @@ export class YAMLCompletion extends JSONCompletion {
}
if (propertySchema.enum) {
if (!value && propertySchema.enum.length === 1) {
value = this.getInsertTextForGuessedValue(propertySchema.enum[0], '');
value = ' ' + this.getInsertTextForGuessedValue(propertySchema.enum[0], '');
}
nValueProposals += propertySchema.enum.length;
}
if (isDefined(propertySchema.default)) {
if (!value) {
value = this.getInsertTextForGuessedValue(propertySchema.default, '');
value = ' ' + this.getInsertTextForGuessedValue(propertySchema.default, '');
}
nValueProposals++;
}
if (Array.isArray(propertySchema.examples) && propertySchema.examples.length) {
if (!value) {
value = this.getInsertTextForGuessedValue(propertySchema.examples[0], '');
value = ' ' + this.getInsertTextForGuessedValue(propertySchema.examples[0], '');
}
nValueProposals += propertySchema.examples.length;
}
Expand Down Expand Up @@ -740,7 +740,7 @@ export class YAMLCompletion extends JSONCompletion {
}
}
if (!value || nValueProposals > 1) {
value = '$1';
value = ' $1';
}
return resultText + value + separatorAfter;
}
Expand Down
8 changes: 8 additions & 0 deletions test/autoCompletion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ suite('Auto Completion Tests', () => {
}).then(done, done);
});

it('Autocomplete on default value (without :)', done => {
const content = 'directory';
const completion = parseSetup(content, 10);
completion.then(function (result) {
assert.equal(result.items[2].insertText, 'directory: ${1:bower_components}');
}).then(done, done);
});

it('Autocomplete on default value (without value content)', done => {
const content = 'directory: ';
const completion = parseSetup(content, 12);
Expand Down