Skip to content

Commit

Permalink
feat: unify string insert text for array and property
Browse files Browse the repository at this point in the history
  • Loading branch information
p-spacek committed May 29, 2024
1 parent 7203630 commit c5188d6
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/languageservice/services/yamlCompletion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down
26 changes: 22 additions & 4 deletions test/autoCompletion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand All @@ -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, {
Expand Down Expand Up @@ -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, {
Expand All @@ -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, {
Expand Down

0 comments on commit c5188d6

Please sign in to comment.