asciidoctor-intellij-plugin icon indicating copy to clipboard operation
asciidoctor-intellij-plugin copied to clipboard

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

Open dnbln opened this issue 4 years ago • 16 comments

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?

dnbln avatar Jan 02 '21 23:01 dnbln

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?

ahus1 avatar Jan 03 '21 11:01 ahus1

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

dnbln avatar Jan 03 '21 13:01 dnbln

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?

ahus1 avatar Jan 03 '21 14:01 ahus1

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.

mojavelinux avatar Jan 03 '21 19:01 mojavelinux

@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

ahus1 avatar Jan 03 '21 19:01 ahus1

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?

dnbln avatar Jan 03 '21 20:01 dnbln

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

mojavelinux avatar Jan 03 '21 21:01 mojavelinux

@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.

ahus1 avatar Jan 03 '21 22:01 ahus1

Ok, thank you

dnbln avatar Jan 03 '21 22:01 dnbln

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

ahus1 avatar Jan 04 '21 21:01 ahus1

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?

markushaslinger avatar Aug 31 '23 07:08 markushaslinger

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 avatar Jan 17 '24 10:01 bric3

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

image

bric3 avatar Jan 17 '24 10:01 bric3

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 avatar Jan 18 '24 08:01 ahus1

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.

ahus1 avatar Jan 18 '24 08:01 ahus1

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.

bric3 avatar Jan 18 '24 08:01 bric3