Skip to content

Commit

Permalink
WIP Include path to completion item for xref
Browse files Browse the repository at this point in the history
one test provided when at same level

todo:
- test with file at different level
- implement the feature :-)

part of asciidoctor#648

Signed-off-by: Aurélien Pupier <apupier@redhat.com>
  • Loading branch information
apupier committed Nov 26, 2022
1 parent eebea11 commit d278a82
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/test/xrefCompletionProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ suite('Xref CompletionsProvider', () => {
label: 'aShortHandID[]',
})
})
test('Should return ids declared using the longhand syntax as completion after "xref:"', async () => {
test('Should return ids declared using the longhand syntax as completion after "xref:" from other document', async () => {
const fileToAutoComplete = vscode.Uri.file(`${root}/fileToAutoComplete.adoc`)
await vscode.workspace.fs.writeFile(fileToAutoComplete, Buffer.from('xref:'))
createdFiles.push(fileToAutoComplete)
Expand All @@ -63,6 +63,22 @@ suite('Xref CompletionsProvider', () => {
const file = await vscode.workspace.openTextDocument(fileToAutoComplete)
const completionsItems = await xrefProvider.provideCompletionItems(file, new Position(0, 5))
const filteredCompletionItems = completionsItems.filter((completionItem) => completionItem.label === 'longHandID[]')
assert.deepStrictEqual(filteredCompletionItems[0], {
kind: vscode.CompletionItemKind.Reference,
label: 'longHandID[]',
insertText: 'fileToAppearInAutoComplete.adoc#longHandID[]',
})
})
test('Should return ids declared using the longhand syntax as completion after "xref:" from same document', async () => {
const fileToAutoComplete = vscode.Uri.file(`${root}/fileToAutoCompleteFromSameFile.adoc`)
await vscode.workspace.fs.writeFile(fileToAutoComplete, Buffer.from(`[id=longHandID]
xref:`))
createdFiles.push(fileToAutoComplete)

const file = await vscode.workspace.openTextDocument(fileToAutoComplete)
const completionsItems = await xrefProvider.provideCompletionItems(file, new Position(2, 5))
const filteredCompletionItems = completionsItems.filter((completionItem) => completionItem.label === 'longHandID[]')
assert.deepStrictEqual(filteredCompletionItems[0], {
kind: vscode.CompletionItemKind.Reference,
label: 'longHandID[]',
Expand Down

0 comments on commit d278a82

Please sign in to comment.