From c5188d69789ef78157cf70f9f3c39eff2e8f5b58 Mon Sep 17 00:00:00 2001 From: Petr Spacek Date: Tue, 28 May 2024 12:30:43 +0200 Subject: [PATCH] feat: unify string insert text for array and property --- .../services/yamlCompletion.ts | 1 + test/autoCompletion.test.ts | 26 ++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/languageservice/services/yamlCompletion.ts b/src/languageservice/services/yamlCompletion.ts index 513a23d6..485528fa 100644 --- a/src/languageservice/services/yamlCompletion.ts +++ b/src/languageservice/services/yamlCompletion.ts @@ -775,6 +775,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 eba8fa6d..7f30735c 100644 --- a/test/autoCompletion.test.ts +++ b/test/autoCompletion.test.ts @@ -2866,7 +2866,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, { @@ -2878,7 +2883,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, { @@ -2915,7 +2925,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, { @@ -2927,7 +2942,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, {