asciidoctor-vscode
asciidoctor-vscode copied to clipboard
do not duplicate attributes on include suggestion
In asciidoc.provider.ts
const globalVariableDefinitions = documentText.match(/:\S+:.*/g)
leads to duplicate entries in the suggestions when i define an attribute in the same file.
:srcdir: ../two
include::{srcdir}/

and further down it appears again (coming from a different provider)

We should not use a regular expression. Instead, we should use Asciidoctor.js to parse the AsciiDoc document using the header_only option. Then, we can retrieve attributes using: Document#getAttributes
It might be because attributeReferenceProvider will return it as well: https://github.com/asciidoctor/asciidoctor-vscode/blob/b65f1c171ce828e71f784cfdf8c5f2bc6e429f66/src/features/attributeReferenceProvider.ts#L5
We should probably remove const globalVariableDefinitions = documentText.match(/:\S+:.*/g).
I think we should revise our completion item providers to make sure that we don't return the same items more than once.
That's the case. The duplicate comes from AttributeReferenceProvider.
It should be better in the latest version. Feel free to open a new issue if we can improve it further.