forked from asciidoctor/asciidoctor-vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix completion after xref: for old double-square bracket notation
part of asciidoctor#648 - it was broken during enforcing code style, the regular expression was not correctly converted asciidoctor@cd477c7 - added a test - The previous was not very nice in the sense that it is not inserting the file path but only the label, but maybe it is enough if there is the right include? Signed-off-by: Aurélien Pupier <apupier@redhat.com>
- Loading branch information
Showing
2 changed files
with
45 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import 'mocha' | ||
import * as vscode from 'vscode' | ||
import assert from 'assert' | ||
import { xrefProvider } from '../providers/xref.provider' | ||
import { Position } from 'vscode' | ||
|
||
let root | ||
|
||
suite('Xref CompletionsProvider', () => { | ||
const createdFiles: vscode.Uri[] = [] | ||
setup(() => { | ||
root = vscode.workspace.workspaceFolders[0].uri.fsPath | ||
}) | ||
teardown(async () => { | ||
for (const createdFile of createdFiles) { | ||
await vscode.workspace.fs.delete(createdFile) | ||
} | ||
}) | ||
test('Should return other ids from old style double-brackets as completion after "xref:"', async () => { | ||
const fileToAutoComplete = vscode.Uri.file(`${root}/fileToAutoComplete.adoc`) | ||
await vscode.workspace.fs.writeFile(fileToAutoComplete, Buffer.from('xref:')) | ||
createdFiles.push(fileToAutoComplete) | ||
|
||
const fileThatShouldAppearInAutoComplete = vscode.Uri.file(`${root}/fileToAppearInAutoComplete.adoc`) | ||
await vscode.workspace.fs.writeFile(fileThatShouldAppearInAutoComplete, Buffer.from('[[anOldStyleID]]')) | ||
createdFiles.push(fileThatShouldAppearInAutoComplete) | ||
|
||
const file = await vscode.workspace.openTextDocument(fileToAutoComplete) | ||
const completionsItems = await xrefProvider.provideCompletionItems(file, new Position(0, 5)) | ||
const filteredCompletionItems = completionsItems.filter((completionItem) => completionItem.label === 'anOldStyleID[]') | ||
assert.deepStrictEqual(filteredCompletionItems[0], { | ||
kind: vscode.CompletionItemKind.Reference, | ||
label: 'anOldStyleID[]', | ||
}) | ||
}) | ||
}) |