diff --git a/src/languageservice/services/yamlCompletion.ts b/src/languageservice/services/yamlCompletion.ts index 96ec4995..b6ad408e 100644 --- a/src/languageservice/services/yamlCompletion.ts +++ b/src/languageservice/services/yamlCompletion.ts @@ -956,6 +956,7 @@ export class YamlCompletion { insertText, insertTextFormat: InsertTextFormat.Snippet, documentation: this.fromMarkup(propertySchema.markdownDescription) || propertySchema.description || '', + ...(schema.schema.title ? { data: { schemaTitle: schema.schema.title } } : undefined), }, didOneOfSchemaMatches ); diff --git a/test/autoCompletion.test.ts b/test/autoCompletion.test.ts index 897c11f6..6eaf3b71 100644 --- a/test/autoCompletion.test.ts +++ b/test/autoCompletion.test.ts @@ -3220,7 +3220,12 @@ describe('Auto Completion Tests', () => { expect(result.items.length).equal(5); expect(result.items[0]).to.deep.equal( - createExpectedCompletion('type', 'type: ${1|typeObj1,typeObj2|}', 0, 0, 0, 0, 10, 2, { documentation: '' }) + createExpectedCompletion('type', 'type: ${1|typeObj1,typeObj2|}', 0, 0, 0, 0, 10, 2, { + documentation: '', + data: { + schemaTitle: 'Object1', + }, + }) ); expect(result.items[1]).to.deep.equal( createExpectedCompletion('Object1', 'type: typeObj1\noptions:\n label: ', 0, 0, 0, 0, 7, 2, { @@ -3232,7 +3237,12 @@ describe('Auto Completion Tests', () => { }) ); expect(result.items[2]).to.deep.equal( - createExpectedCompletion('options', 'options:\n label: ', 0, 0, 0, 0, 10, 2, { documentation: '' }) + createExpectedCompletion('options', 'options:\n label: ', 0, 0, 0, 0, 10, 2, { + documentation: '', + data: { + schemaTitle: 'Object1', + }, + }) ); expect(result.items[3]).to.deep.equal( createExpectedCompletion('obj2', 'type: typeObj2\noptions:\n description: ', 0, 0, 0, 0, 7, 2, { @@ -3269,7 +3279,12 @@ describe('Auto Completion Tests', () => { expect(result.items.length).equal(5); expect(result.items[0]).to.deep.equal( - createExpectedCompletion('type', 'type: ${1|typeObj1,typeObj2|}', 0, 2, 0, 2, 10, 2, { documentation: '' }) + createExpectedCompletion('type', 'type: ${1|typeObj1,typeObj2|}', 0, 2, 0, 2, 10, 2, { + documentation: '', + data: { + schemaTitle: 'Object1', + }, + }) ); expect(result.items[1]).to.deep.equal( createExpectedCompletion('Object1', 'type: typeObj1\n options:\n label: ', 0, 2, 0, 2, 7, 2, { @@ -3281,7 +3296,10 @@ describe('Auto Completion Tests', () => { }) ); expect(result.items[2]).to.deep.equal( - createExpectedCompletion('options', 'options:\n label: ', 0, 2, 0, 2, 10, 2, { documentation: '' }) + createExpectedCompletion('options', 'options:\n label: ', 0, 2, 0, 2, 10, 2, { + documentation: '', + data: { schemaTitle: 'Object1' }, + }) ); expect(result.items[3]).to.deep.equal( createExpectedCompletion('obj2', 'type: typeObj2\n options:\n description: ', 0, 2, 0, 2, 7, 2, {