When creating a new field, incorrectly IntelliJ suggests renaming it

Answered

When I use the “create field” refactoring in IntelliJ like this:

…this works fine, but in the list of suggested field names, a shortened name is almost always shown first, like this:

This means that if I just press Enter (to confirm), a “Rename constructor parameters” dialog appears:

This is extremely frustrating, since it basically makes it “impossible” (or at least unnecessary hard) to use this refactoring to just create a field with the same name as the constructor parameter.

I've asked my colleagues about this, but their IntelliJ does not behave like this. Any ideas? Here's my IntelliJ version and some details about my environment:

IntelliJ IDEA 2023.3 (Ultimate Edition)
Build #IU-233.11799.241, built on December 2, 2023
Runtime version: 17.0.9+7-b1087.7 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 6.1.0-13-amd64

0
9 comments

Hello Per, does the behaviour change for you if you disable option “Sort completion suggestions” in “Settings | Editor | General | Code Completion”?

0

Thanks for the suggestion Sergei Riabinin. I tried with this, both disabling just Java and then disabling this feature altogether (last screenshot below). Doesn't help, still gives the suggestions sorted incorrectly.

One interesting observation: there seems to be a “Sort by Name” option, but enabling/disabling it doesn't seem to make much of a difference on my machine. Don't know if it's relevant or not, but still worth pointing it out.

0

Hi Per, sorry for a delayed reply.

We'd suggest you to update to the recent version, most probably issue with 2023.3 was solved in this ticket. Trying on latest versions, we couldn't reproduce same behaviour as in the original description, pressing `Enter` does not triggers the modal dialog and standrad name is applied.

Could you please check on 2023.3.2?

0

Hi Sergei Riabinin , thanks for your reply. I tried updating now but it behaves the same, unfortunately:

Here's the "proof: that the update worked as intended and that I'm indeed running the new version:

IntelliJ IDEA 2023.3.2 (Ultimate Edition)
Build #IU-233.13135.103, built on December 20, 2023
Licensed to <removed>
Subscription is active until <removed>
Runtime version: 17.0.9+7-b1087.9 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Linux 6.1.0-16-amd64
GC: G1 Young Generation, G1 Old Generation
Memory: 3500M
Cores: 20
Registry:
 ide.balloon.shadow.size=0
 debugger.watches.in.variables=false
 scala.erase.compiler.process.jdk.once=false
Non-Bundled Plugins:
 de.netnexus.camelcaseplugin (3.0.12)
 com.andrewbrookins.wrap_to_column (1.8.0)
 name.kropp.intellij.makefile (233.11799.188)
 ir.msdehghan.plugins.ansible (0.92)
 org.jetbrains.plugins.go (233.11799.196)
 org.jetbrains.plugins.ruby (233.11799.300)
 com.wakatime.intellij.plugin (14.3.2)
 com.attachme (1.2.4)
 CheckStyle-IDEA (5.85.0)
 ru.artyushov (1.4.0)
 Pythonid (233.11799.241)
 uk.co.ben-gibson.remote.repository.mapper (4.4.0)
 com.jetbrains.php (233.11799.241)
 com.fapiko.jetbrains.plugins.better_direnv (1.2.2)
 org.intellij.scala (2023.3.17)
Kotlin: 233.13135.103-IJ
Current Desktop: X-Cinnamon
0

Could you pls check if it helps to:
1) disable all non-bundled plugins and restart IDEA
2) go through these steps
3) you can also try to apply default settings after that ("File | Manage IDE Settings | Restore default settings") and delete hidden `.idea` folder in the project and check if it has any affect

0

Thanks. Disabling the plugins is doable, I can test that first. Running a repair is also fine. However, doing a full restore to default settings is like something that I prefer to avoid. IIRC, I've done that before when my IntelliJ settings were broken and I'm not so happy to lose my custom settings for the project given that it's the main project that I work with the most.

I'll try the other suggestions first and get back to you, let's see if it helps us find the cause for this.

0

Thanks for the suggestion; this option is already enabled in my settings. Unchecking it does indeed suggest even shorter names :D but keeping it checked doesn't seem to help.

I still believe it's the “Short by Name” option (mentioned in one of my previous screenshots) that is “broken” for me somehow. I can check it, but unchecking doesn't seem to do anything meaningful AFAICT. So like you say, perhaps a full reset of the settings is the “easy” way out..

0

Please sign in to leave a comment.