Skip to content

Commit

Permalink
redhat-developer#392 fix indentation for object in array completion
Browse files Browse the repository at this point in the history
Signed-off-by: Yevhen Vydolob <[email protected]>
  • Loading branch information
evidolob committed Feb 24, 2021
1 parent 20fecf5 commit 3bb19b2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/languageservice/services/yamlCompletion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -893,10 +893,10 @@ export class YAMLCompletion extends JSONCompletion {
value = ' $1';
break;
case 'object':
value = `\n${this.indentation}`;
value = `\n${ident}`;
break;
case 'array':
value = `\n${this.indentation}- `;
value = `\n${ident}- `;
break;
case 'number':
case 'integer':
Expand Down
11 changes: 11 additions & 0 deletions test/autoCompletion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1880,5 +1880,16 @@ describe('Auto Completion Tests', () => {
assert.equal(result.items[0].label, '- (array item) 1');
});
});

it('Array anyOf two objects completion indentation', async () => {
const schema = require(path.join(__dirname, './fixtures/testArrayCompletionSchema.json'));
languageService.addSchema(SCHEMA_ID, schema);
const content = 'test_array_anyOf_2objects:\n - obj';
const completion = await parseSetup(content, content.length);
expect(completion.items.length).is.equal(2);
const obj1 = completion.items.find((it) => it.label === 'obj1');
expect(obj1).is.not.undefined;
expect(obj1.textEdit.newText).equal('obj1:\n ');
});
});
});

0 comments on commit 3bb19b2

Please sign in to comment.