-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: suggest hyphen in array #901
base: main
Are you sure you want to change the base?
Changes from 2 commits
519f984
d0872b1
0432be8
86a72ed
f7df5fc
8e4d05f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1488,6 +1488,39 @@ describe('Auto Completion Tests', () => { | |
.then(done, done); | ||
}); | ||
|
||
it('Array of enum autocomplete on 2nd position without `-`', (done) => { | ||
schemaProvider.addSchema(SCHEMA_ID, { | ||
type: 'object', | ||
properties: { | ||
references: { | ||
type: 'array', | ||
items: { | ||
enum: ['Test'], | ||
}, | ||
}, | ||
}, | ||
}); | ||
const content = 'references:\n - Test\n |\n|'; | ||
const completion = parseSetup(content); | ||
completion | ||
.then(function (result) { | ||
assert.deepEqual( | ||
result.items.map((i) => ({ label: i.label, insertText: i.insertText })), | ||
[ | ||
{ | ||
insertText: 'Test', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there should be '- Test' insert text, but it's another problem There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you file that as an issue? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I fixed it in this PR the end... |
||
label: 'Test', | ||
}, | ||
{ | ||
insertText: '- $1\n', | ||
label: '- (array item) ', | ||
}, | ||
] | ||
); | ||
}) | ||
.then(done, done); | ||
}); | ||
|
||
it('Array of objects autocomplete with 4 space indentation check', async () => { | ||
const languageSettingsSetup = new ServiceSetup().withCompletion().withIndentation(' '); | ||
languageService.configure(languageSettingsSetup.languageSettings); | ||
|
@@ -1926,7 +1959,8 @@ describe('Auto Completion Tests', () => { | |
assert.equal(result.items.length, 3, `Expecting 3 items in completion but found ${result.items.length}`); | ||
|
||
const resultDoc2 = await parseSetup(content, content.length); | ||
assert.equal(resultDoc2.items.length, 0, `Expecting no items in completion but found ${resultDoc2.items.length}`); | ||
assert.equal(resultDoc2.items.length, 1, `Expecting 1 item in completion but found ${resultDoc2.items.length}`); | ||
assert.equal(resultDoc2.items[0].label, '- (array item) '); | ||
}); | ||
|
||
it('should handle absolute path', async () => { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unify the code for both scenarios. If a schema contains
items
it's an array. No need to check iftype === 'object'