Skip to content
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

Autocompletion for image:: and include:: files #377

Open
rdmueller opened this issue Nov 17, 2020 · 11 comments
Open

Autocompletion for image:: and include:: files #377

rdmueller opened this issue Nov 17, 2020 · 11 comments
Assignees
Labels

Comments

@rdmueller
Copy link
Member

The IntelliJ-Asciidoctor-Plugin manages to do an autocomplete on image:: and include:: macros to select a file.

This is quite helpful and avoids typos. I would like to see this feature here in the asciidoctor-vscode plugin :-)

Details:

  • You start to type include:: and press ctrl+space.
  • a drop down menu opens with a list of current folders and files to select from
  • you select a folder and the next drop down opens, until you select a file
  • you close your include:: macro by adding []
@rdmueller rdmueller added 💬 discussion Disccussion on new features, projects, etc... ✨ enhancement labels Nov 17, 2020
@d-koppenhagen
Copy link
Contributor

@rdmueller should it really be necessary to press a keyboard shortcut like ctrl + space? I thing it would be even more easy and intuitive if the completion starts directly after typing include::.
This could work just like in the PathIntellisense Plugin (see here: https://github.com/ChristianKohler/PathIntellisense). WHat do you think about it?

@rdmueller
Copy link
Member Author

sure! even better if you don't have to activate it 😀

@d-koppenhagen
Copy link
Contributor

d-koppenhagen commented Dec 1, 2020

@rdmueller in addition, I added autocompletion also when using with defined variables. The completion will take the he pathes defined in the variable selected from the completion list and starts to search for child elements inside the directory

@rdmueller
Copy link
Member Author

wow! sounds perfect!
And do I see a PR there? awesome!

@d-koppenhagen
Copy link
Contributor

Yes. There is still a small problem with just a specific case I linked a stackoverflow issue. Currently I have no idea how to solve it

@eiswind
Copy link
Contributor

eiswind commented Mar 7, 2022

is there any progress on this? atm it seems a little broken to me.
Broken means it doesn't work when the adoc file is not in the root of the project.

@ggrossetie
Copy link
Member

is there any progress on this? atm it seems a little broken to me.

Could you please be more specific?
Maybe you are referring to the fact that built-in attributes are included in the auto-completion?

This has been fixed in #529 and will be available in the next release.
Here's what I get using the master branch (next release):

autocomplete

@eiswind
Copy link
Contributor

eiswind commented Mar 7, 2022

I have asciidoc files that are in some subfolder of the project. I found that the completion seems to resolve the files and folders to the root of the project, which makes it almost useless. And in my case i use an attribute to resolve the source folder, which seems to cause even more confusion.
Bildschirmfoto von 2022-03-07 18-21-16

Here you can see the folders from the project root:

Bildschirmfoto von 2022-03-07 18-26-01

@ggrossetie
Copy link
Member

ggrossetie commented Mar 7, 2022

@eiswind Thanks that's really valuable. I think we should open new issues to track these feature enhancements.

I found that the completion seems to resolve the files and folders to the root of the project, which makes it almost useless

I don't think we are using the path before the cursor but we definitely should. In your case {srcdir}/003_spring_boot/ is ignored and you will get the same suggestions no matter where in the target path your cursor is.

And in my case i use an attribute to resolve the source folder, which seems to cause even more confusion.

It seems that we are trying to resolve the attribute but I guess srcdir is defined in another file?

if (entryDir.startsWith('{')) {
const variableName = entryDir.replace('{', '').replace('}', '')
const match = documentText.match(new RegExp(`:${variableName}:.*`, 'g'))
if (match && match[0]) {
entryDir = match[0].replace(`:${variableName}: `, '')
}
}

Here you can see the folders from the project root:

I believe this is intended but I think we should see first files available within the current directory.

@eiswind
Copy link
Contributor

eiswind commented Mar 7, 2022 via email

@ggrossetie
Copy link
Member

The attribute is defined in the same file. You can see that in the first screenshot.

Oh I see... that does not work because the current implementation does not handle ifndef macro 😞

Plus I think that relative includes are always resolved to the directory the file lives in, but I am not completely sure about that.
Please let me know if I can provide assistance.

I will take a closer look, thanks for your feedback that's really valuable 👍🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants