question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inconsistency with "Duplicate Line"

See original GitHub issue

Describe 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:

  1. 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);
  1. Now you want both lines 3 and 4 duplicated and x1 turned into x2.

In case you properly select everything:

image

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:

image

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:open
  • Created 2 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
BernhardBlncommented, Apr 6, 2021

Not quite the fix I hoped for but fair enough 😂

1reaction
krasacommented, Apr 6, 2021

Oh, found it 😃 That is wrong 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

Duplicate Code and its top 4 harmful effects - Codegrip
People might consider code duplication acceptable but in reality, it poses greater problems to your software than what you may have thought. Even...
Read more >
Excel duplicate line meny at the same time and change the ...
I have excel sheet with 500 lines of data how can i duplicate all lines so that there will be the same data...
Read more >
Inconsistency in Validate duplicates in datagridview vb.net
Your problem is with this line If clave = dgvdetalle. ... The loop is not changing the current row, it is only changing...
Read more >
Analyze duplicates | IntelliJ IDEA Documentation - JetBrains
IntelliJ IDEA helps you find repetitive blocks of code in a certain set of files by means of the Duplicated code fragment inspection....
Read more >
Eliminating Duplicate Lines - allsyed
One of the common problems when working with plain text is duplicate lines. They are bad and in most of the cases we...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found