Skip to content

Commit c5188d6

Browse files
committed
feat: unify string insert text for array and property
1 parent 7203630 commit c5188d6

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

src/languageservice/services/yamlCompletion.ts

+1
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,7 @@ export class YamlCompletion {
775775
insertText,
776776
insertTextFormat: InsertTextFormat.Snippet,
777777
documentation: this.fromMarkup(propertySchema.markdownDescription) || propertySchema.description || '',
778+
...(schema.schema.title ? { data: { schemaTitle: schema.schema.title } } : undefined),
778779
},
779780
didOneOfSchemaMatches
780781
);

test/autoCompletion.test.ts

+22-4
Original file line numberDiff line numberDiff line change
@@ -2866,7 +2866,12 @@ describe('Auto Completion Tests', () => {
28662866

28672867
expect(result.items.length).equal(5);
28682868
expect(result.items[0]).to.deep.equal(
2869-
createExpectedCompletion('type', 'type: ${1|typeObj1,typeObj2|}', 0, 0, 0, 0, 10, 2, { documentation: '' })
2869+
createExpectedCompletion('type', 'type: ${1|typeObj1,typeObj2|}', 0, 0, 0, 0, 10, 2, {
2870+
documentation: '',
2871+
data: {
2872+
schemaTitle: 'Object1',
2873+
},
2874+
})
28702875
);
28712876
expect(result.items[1]).to.deep.equal(
28722877
createExpectedCompletion('Object1', 'type: typeObj1\noptions:\n label: ', 0, 0, 0, 0, 7, 2, {
@@ -2878,7 +2883,12 @@ describe('Auto Completion Tests', () => {
28782883
})
28792884
);
28802885
expect(result.items[2]).to.deep.equal(
2881-
createExpectedCompletion('options', 'options:\n label: ', 0, 0, 0, 0, 10, 2, { documentation: '' })
2886+
createExpectedCompletion('options', 'options:\n label: ', 0, 0, 0, 0, 10, 2, {
2887+
documentation: '',
2888+
data: {
2889+
schemaTitle: 'Object1',
2890+
},
2891+
})
28822892
);
28832893
expect(result.items[3]).to.deep.equal(
28842894
createExpectedCompletion('obj2', 'type: typeObj2\noptions:\n description: ', 0, 0, 0, 0, 7, 2, {
@@ -2915,7 +2925,12 @@ describe('Auto Completion Tests', () => {
29152925

29162926
expect(result.items.length).equal(5);
29172927
expect(result.items[0]).to.deep.equal(
2918-
createExpectedCompletion('type', 'type: ${1|typeObj1,typeObj2|}', 0, 2, 0, 2, 10, 2, { documentation: '' })
2928+
createExpectedCompletion('type', 'type: ${1|typeObj1,typeObj2|}', 0, 2, 0, 2, 10, 2, {
2929+
documentation: '',
2930+
data: {
2931+
schemaTitle: 'Object1',
2932+
},
2933+
})
29192934
);
29202935
expect(result.items[1]).to.deep.equal(
29212936
createExpectedCompletion('Object1', 'type: typeObj1\n options:\n label: ', 0, 2, 0, 2, 7, 2, {
@@ -2927,7 +2942,10 @@ describe('Auto Completion Tests', () => {
29272942
})
29282943
);
29292944
expect(result.items[2]).to.deep.equal(
2930-
createExpectedCompletion('options', 'options:\n label: ', 0, 2, 0, 2, 10, 2, { documentation: '' })
2945+
createExpectedCompletion('options', 'options:\n label: ', 0, 2, 0, 2, 10, 2, {
2946+
documentation: '',
2947+
data: { schemaTitle: 'Object1' },
2948+
})
29312949
);
29322950
expect(result.items[3]).to.deep.equal(
29332951
createExpectedCompletion('obj2', 'type: typeObj2\n options:\n description: ', 0, 2, 0, 2, 7, 2, {

0 commit comments

Comments
 (0)