asciidoctor / asciidoctor-intellij-plugin

AsciiDoc plugin for products on the IntelliJ platform (IDEA, RubyMine, etc)
https://intellij-asciidoc-plugin.ahus1.de/
Apache License 2.0
349 stars 146 forks source link

ad-tag-include shows up in non-asciidoc files' auto complete #632

Open dnbln opened 3 years ago

dnbln commented 3 years ago

Observed vs. expected behavior

ad-tag-include shows up on auto complete everywhere, instead of only in asciidoc files.

Steps to reproduce

Type a in any open editor that is not an asciidoc file(a rust file in this image) image

Environment

Plugin Version: 0.32.7 IntelliJ Details: CLion 2020.3.1 Build #CL-203.6682.181, built on December 30, 2020 Runtime version: 11.0.9.1+11-b1145.63 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Linux 5.9.14-arch1-1 GC: ParNew, ConcurrentMarkSweep Memory: 1987M Cores: 4 Registry: run.processes.with.pty=TRUE, debugger.watches.in.variables=false, ide.tree.collapse.recursively=false, ide.balloon.shadow.size=0 Non-Bundled Plugins: GLSL, IdeaVIM, Key Promoter X, SmarterEditor, String Manipulation, com.alayouni.ansiHighlight, com.chrisrm.idea.MaterialThemeUI, com.fernandojimenez.obsidian.theme, com.intellij.copyright, com.intellij.ideolog, com.intellij.plugins.visualstudiokeymap, com.intellij.plugins.vscodekeymap, com.mallowigi, com.nasmlanguage, com.samdark.intellij-visual-studio-code-dark-plus, idea.goyacc, io.allandequeiroz.random.image.background, nb-mind-map-idea, net.seesharpsoft.intellij.plugins.file-preview, net.vektah.codeglance, org.editorconfig.editorconfigjetbrains, org.jetbrains.plugins.hocon, com.codestream.jetbrains-codestream, uk.co.ben-gibson.remote.repository.mapper, zielu.gittoolbox, com.almightyalpaca.intellij.plugins.discord, mobi.hsz.idea.gitignore, com.jetbrains.codeWithMe, name.kropp.intellij.makefile, Docker, org.toml.lang, tv.codely.codelytv-theme, org.exbin.deltahex.intellij, org.asciidoctor.intellij.asciidoc, org.rust.lang, com.github.ArtsiomCh.NestedBracketsColorer, com.mdrobnak.intellij-lalrpop, ru.adelf.idea.dotenv Current Desktop: GNOME

Possible fix?

Change this line to

<option name="AsciiDoc" value="true" />

Or at least add an option to disable it?

ahus1 commented 3 years ago

Thanks for reporting this accurately will all necessary details. Yes, the fix you suggest should fix it. Do you want to provide a pull request?

dnbln commented 3 years ago

Looking at https://github.com/asciidoctor/asciidoctor-intellij-plugin/issues/450#issuecomment-606824111 this might have been intended?

ahus1 commented 3 years ago

Hm, you're right. Thanks for doing the research. So it makes sense to keep it for all languages, as includes would work in all languages.

Could this be better clarified to avoid surprises in the future?

mojavelinux commented 3 years ago

I don't think it's a good idea to use AsciiDoc includes in other languages. While it would work, it really breaks the spirit of the separation and blurs the lines of what AsciiDoc is. If someone wants to do it, that's their choice, but the IDE shouldn't encourage it.

ahus1 commented 3 years ago

@mojavelinux - my last comment was not as precise as it could have been: it is about adding tags to source code files of other languages that will then be used as tags for includes in AsciiDoc.

The following recoding shows how it works inpractice. The hot-key is Ctrl+Alt+T. It adds line comments (for example // or # depending on the language of the file.

tag-for-include

dnbln commented 3 years ago

Finally found how to disable it(Settings > Editor > Live templates). While it's without a doubt useful, my question now is should it really be opt-out of rather than opt-in?

mojavelinux commented 3 years ago

@ahus1 Thanks for clarifying and my apologies for the confusion. That makes perfect sense.

ahus1 commented 3 years ago

@dblanovschi - I assume that this feature would be hard to discover for users it it would be opt-in. Having it as a live template to create an empty tagged snipped to be included and as a surround-with... is helpful for those who want to include source code snippets in their AsciiDoc documents.

I'll update the description "Surround with Tag for include macro" to make it more descriptive.

I recommend that you disable it as you described above if you think you'll not going to use it.

dnbln commented 3 years ago

Ok, thank you

ahus1 commented 3 years ago

Updated description of live template. Update docs in dc7842cc6a6498f621c6290d719dd3490a6c0b7a for Live Templates; also added entry to FAQ.

markushaslinger commented 1 year ago

Since a couple of days typing a and then a space (not tab!) triggers the template. Given that 'a' is quite common in English that really hurts.

adoc_plugin_issue

I'm not sure if that was a change in the plugin, something JB did or if I messed up a setting. @ahus1 I suppose that is not expected behaviour - any ideas?

bric3 commented 8 months ago

Yeah it's super annoying (same as @markushaslinger). I don't think the tag include should be live template either, I'd rather have this as an intention action.

For me it shows everywhere I type english text, e.g. in github PR review comment component :

image

@ahus1 I would really revisit this ! E.g. IJ also has surround actions, and now they appear in their editor floating bar which might be a better fit.

bric3 commented 8 months ago

Also strangely this live template appear when nothing is selected, which should at least be the spirit

image
ahus1 commented 8 months ago

I did another search, and there is this usability issue in tracked for IntelliJ: https://youtrack.jetbrains.com/issue/IDEABKL-7114

They describe how to disable live templates to show up in the auto-completion by changing the registry entry show.live.templates.in.completion. Once you disabled them, there is still the hotkey Ctrl+J (Windows) to trigger them when you need them.

I'm having another look if this can be suppressed somehow in a more standard way.

ahus1 commented 8 months ago

Also strangely this live template appear when nothing is selected

@bric3 - the template still makes sense if you start with an include tag in a non-AsciiDoc file and then start typing the content between the start and end.

Again, I'll have another look how this can be changed in addition to the registry option stated above.

bric3 commented 8 months ago

They describe how to disable live templates to show up in the auto-completion

Yeah but I do like to have the other live template in the completion.