Skip to content

Commit b9a8f2d

Browse files
authored
Merge pull request #245 from fbaligand/master
yaml completion: add a space between ':' and value
2 parents 62fa41c + 2d8f356 commit b9a8f2d

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/languageservice/services/yamlCompletion.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -684,19 +684,19 @@ export class YAMLCompletion extends JSONCompletion {
684684
}
685685
if (propertySchema.enum) {
686686
if (!value && propertySchema.enum.length === 1) {
687-
value = this.getInsertTextForGuessedValue(propertySchema.enum[0], '');
687+
value = ' ' + this.getInsertTextForGuessedValue(propertySchema.enum[0], '');
688688
}
689689
nValueProposals += propertySchema.enum.length;
690690
}
691691
if (isDefined(propertySchema.default)) {
692692
if (!value) {
693-
value = this.getInsertTextForGuessedValue(propertySchema.default, '');
693+
value = ' ' + this.getInsertTextForGuessedValue(propertySchema.default, '');
694694
}
695695
nValueProposals++;
696696
}
697697
if (Array.isArray(propertySchema.examples) && propertySchema.examples.length) {
698698
if (!value) {
699-
value = this.getInsertTextForGuessedValue(propertySchema.examples[0], '');
699+
value = ' ' + this.getInsertTextForGuessedValue(propertySchema.examples[0], '');
700700
}
701701
nValueProposals += propertySchema.examples.length;
702702
}
@@ -740,7 +740,7 @@ export class YAMLCompletion extends JSONCompletion {
740740
}
741741
}
742742
if (!value || nValueProposals > 1) {
743-
value = '$1';
743+
value = ' $1';
744744
}
745745
return resultText + value + separatorAfter;
746746
}

test/autoCompletion.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ suite('Auto Completion Tests', () => {
4949
}).then(done, done);
5050
});
5151

52+
it('Autocomplete on default value (without :)', done => {
53+
const content = 'directory';
54+
const completion = parseSetup(content, 10);
55+
completion.then(function (result) {
56+
assert.equal(result.items[2].insertText, 'directory: ${1:bower_components}');
57+
}).then(done, done);
58+
});
59+
5260
it('Autocomplete on default value (without value content)', done => {
5361
const content = 'directory: ';
5462
const completion = parseSetup(content, 12);

0 commit comments

Comments
 (0)