xylo / intellij-postfix-templates

Custom Postfix Templates for Intellij IDEA
https://plugins.jetbrains.com/plugin/9862-custom-postfix-templates
Apache License 2.0
526 stars 94 forks source link

Cursor position doesn't match $END$ #205

Closed vivekmore closed 2 years ago

vivekmore commented 3 years ago

I'm trying to add a simple template:

.assertThatThrownBy : assertThatThrownBy
    ANY [org.assertj.core.api.Assertions]                         →  org.assertj.core.api.Assertions.assertThatThrownBy(() -> $expr$).isInstanceOf($END$$exc$); [USE_STATIC_IMPORTS]

Here's what's happening:

https://user-images.githubusercontent.com/2099329/132078828-056d460a-603d-4d67-8250-7cb7a51c367f.mov

OR for

.assertThatThrownBy : assertThatThrownBy
    ANY [org.assertj.core.api.Assertions]                         →  org.assertj.core.api.Assertions.assertThatThrownBy(() -> $expr$).isInstanceOf($END$); [USE_STATIC_IMPORTS]

Here's what's happening:

https://user-images.githubusercontent.com/2099329/132078886-70b4836e-81c4-48c6-bf51-2a59707ede5e.mov


IntelliJ IDEA 2021.2.2 Preview (Ultimate Edition) Build #IU-212.5284.19, built on September 1, 2021 Runtime version: 11.0.12+7-b1504.27 x86_64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. macOS 11.5.2 GC: G1 Young Generation, G1 Old Generation Memory: 6144M Cores: 12 Non-Bundled Plugins: net.seesharpsoft.intellij.plugins.csv (2.17.1), com.markskelton.one-dark-theme (5.3.0), FrameSwitcher (3.27.0-203), google-java-format (1.9.0.1), manjaro.mpb (1.6), com.intellij.javafx (1.0.3), com.arcticicestudio.nord.jetbrains (0.13.0), org.antlr.intellij.plugin (1.16), zielu.gittoolbox (212.7.6), com.sunny.plugin.MockitoGenPlugin (1.4.0), org.sonarlint.idea (5.2.0.35150), org.asciidoctor.intellij.asciidoc (0.33.19), com.intellij.kubernetes (212.5284.17), MavenRunHelper (4.15.212.000.0), String Manipulation (8.15.203.000.3), Builder Generator (1.1.8), VisualVMLauncher (1.20.203.4204.0), org.jetbrains.kotlin (212-1.5.30-release-409-IJ4638.7), com.jetbrains.edu (2021.8-2021.2-298), org.mapstruct.intellij (1.3.0), de.endrullis.idea.postfixtemplates (2.12.1.212), lermitage.intellij.extra.icons (1.61.0.203) Kotlin: 212-1.5.30-release-409-IJ4638.7

xylo commented 2 years ago

Looks like the automatic line wrap interferes with the final cursor position.

Unfortunately, the template expansion is handled by IDEA itself. Thus, I expect the same to happen when you use integrated postfix templates from IDEA. I will test it and file a bug report on youtrack...

xylo commented 2 years ago

Hm, I could not reproduce the bug. It seems that IDEA has already changed the automatic line wrapping for template expansions. The line wrapping is now done after the template expansion. So the issue seems to be solved in IDEA 2022.2.