Inconsistency with "Duplicate Line"
See original GitHub issueDescribe the bug I feel there is some inconsistency regarding the “duplicate and increment” feature.
In the docs it is mentioned that it “duplicates the line” which it does when you just have the cursor in the current line. It does not duplicate the full lines however when you make a selection.
IntelliJ internally has two different commands, “duplicate” and “duplicate line”, where the latter always duplicates the full lines.
I think it would make more sense to duplicate full lines rather than just selections (or at least make it configurable in the settings).
To Reproduce Steps to reproduce the behavior:
- Have a statement that takes more than one line, e.g.
int x1 = 5;
int x2 = 10;
System.out.println("some very very very very very very long text plus the content of " +
x1);
- Now you want both lines 3 and 4 duplicated and x1 turned into x2.
In case you properly select everything:
and then choose “duplicate and increment”, this will work as expected:
System.out.println("some very very very very very very long text plus the content of " +
x1);
System.out.println("some very very very very very very long text plus the content of " +
x2);
However, if you just select just somewhere in the middle, like this:
this will produce broken code:
int x1 = 5;
int x2 = 10;
System.out.println("some very very very very very very long text plus the content of " +
x1y very very very very long text plus the content of " + x2);
Expected behavior
The line duplication should work the same way as the “duplicate line” feature in IntelliJ, duplicating whole lines instead of just the selection.
Environment : IntelliJ IDEA 2020.3.3 (Ultimate Edition) Build #IU-203.7717.56, built on March 15, 2021 Licensed to Bernhard Streit Subscription is active until April 24, 2021. Runtime version: 11.0.10+8-b1145.96 x86_64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. macOS 10.16 GC: ParNew, ConcurrentMarkSweep Memory: 5391M Cores: 16 Registry: analyze.exceptions.on.the.fly=true, ide.tooltip.initialDelay=674, ide.appIcon.requestAttention=false Non-Bundled Plugins: AceJump, IdeaVIM, org.jetbrains.IdeaVim-EasyMotion, com.github.holgerbrandl.pasteimages/, google-java-format, com.crunch42.openapi, EclipseCodeFormatter, GrepConsole, String Manipulation, com.dubreuia, com.krrrr38.idea.mockito.postfix, com.sunny.plugin.MockitoGenPlugin, com.jetbrains.codeWithMe, idea.plugin.protoeditor, org.sonarlint.idea, MavenRunHelper, intellij.prettierJS, org.jetbrains.kotlin, org.bitstrings.idea.plugins.TestInsanity, org.mapstruct.intellij, PlantUML integration
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Not quite the fix I hoped for but fair enough 😂
Oh, found it 😃 That is wrong 😃