asciidoctor-vscode icon indicating copy to clipboard operation
asciidoctor-vscode copied to clipboard

do not duplicate attributes on include suggestion

Open eiswind opened this issue 3 years ago • 3 comments
trafficstars

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}/

Bildschirmfoto vom 2022-08-14 16-28-08

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

Bildschirmfoto vom 2022-08-14 16-28-22

eiswind avatar Aug 14 '22 14:08 eiswind

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

ggrossetie avatar Aug 14 '22 16:08 ggrossetie

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.

ggrossetie avatar Aug 14 '22 21:08 ggrossetie

That's the case. The duplicate comes from AttributeReferenceProvider.

eiswind avatar Aug 15 '22 07:08 eiswind

It should be better in the latest version. Feel free to open a new issue if we can improve it further.

ggrossetie avatar Mar 09 '24 16:03 ggrossetie