5734 - inline rename - hit ENTER accepts suggestion not what I typed


I found an annoying behavior of the inline rename. If I attempt to rename
a variable, e.g. "iter" in code below, it automatically shows me a list of suggestions, e.g. "iterator". If I go ahead and type "i" and then hit ENTER, it doesn't change it to "i" but instead accepts the suggestion "iterator". Argh!

Now if I turn off the inline rename (Editor->Behavior->Rename local variables in place), so that it uses the old Rename Dialog, notice that it doesn't automatically popup the suggestions. I can type "i" and hit ENTER and it changes "iter" to "i". In the Rename Dialog, you have to hit DOWN ARROW to see a list of choices.

I think it should work the same way for inline rename.


There's an additional, related annoyance:
"Pos 1" and "End" keys change the selection in the list, rather than moving the caret to the start/end of the word.

I have switched back to "dialog rename" long ago, because the inline rename is more hassle than it's worth.


I think that problem would also be fixed if they only display the suggestion dropdown menu when you press DOWN ARROW instead of it automatically displaying.

Then Home/End keys will work as expected and work the same as they do in the Dialog rename.

I have filed Jira:

Inline replace - Suggested name dropdown should only appear when DOWN ARROW is pressed, same as Dialog Replace.

I hope they can be fixed before Demetra ships or else in the 6.0.1 release. It really detracts from the useability.


Yes, I keep getting caught by this... I think I'll switch back to the dialog too.


enter always accepts the selected suggestion if there is one.
if you want to rename the variable to what is currently entered, just press escape.


Yes, you can hit ESC and then press ENTER, but the point still stands that the behavior is different between Inline Rename and the Dialog Rename.

To reiterate, in the example above, if I do the following:
1. Invoke Refactor->Rename on "iter".
2. Type "i"
3. press ENTER

Different behavior happens depending whether I have Inline Rename enabled:

Dialog Rename: "iter" becomes "i" as expected.

Inline Rename: "iter" becomes "iterator" because "iterator" was first choice in suggestion dropdown list which is displayed by default.


Yep, this does irritate me as well.

I'm not sure why the smart-completion can't be triggered in the normal way for variable names, rather than defaulting to being turned on.


Reviving this as I still have the problem. Not sure why IDEA behaves this way ... if at least it would highlight the currently selected choice in the dialog, so you know what will be inserted. Then it could probably be changed to, pressing arrow key up selects our written name and Enter doesn't override it with choice from dialog. Pressing ESC all the time before enter is very counter productive - especially when doing more renames.

How are you guys now work with this limitation? Or is there a new setting in the meantime that fixes this behaviour?


Could you please share the short video to clarify the issue? Enter inserts the choice from the drop-down for me.


Hi Serge, thanks for your reply. Yes Enter inserts the choice, but the choice is not highlighted in any way before that. I would rather prefer that it just takes the name I have currently typed instead of the top recommendation. Since variable names are very subjective, it's nice to have recommendations but they should be optional and only apply after I select them. In the example gif, I would like to keep "proj" as the variable name in both cases. First case is just Enter. Second case is cancelling the recommendation with Esc and then Enter (when it stays "proj" after). Would be nice to have a checkbox in the preferences, "Auto-apply top recommendation for inline rename" or something to that effect. Currently having to cancel it every time with Esc is tedious imo. Hope that made it clearer.


The first choice is always preselected for me so it's clear what Enter will do (accept it). If it's not selected, it may be a bug, feel free to report at https://youtrack.jetbrains.com/newIssue?project=IDEA with the sample project, the exact steps to reproduce and the logs (Help | Compress Logs and Show in ...).

You may want to disable the following option and use explicit completion instead only when you need it (Ctrl+Space, etc):


Thanks for your reply and the screenshot, but I don't want to fully disable auto suggestions. It seems to me, IDEA already knows that inline rename is something different than regular code completion because the suggestion dialog doesn't have a highlighted line, but only marks the matching letters (in all matching lines). For Code completion the currently selected line's background is either gray (auto selected when dialog appears) or light blue (when manually selecting) - see screenshots below. And like I said, in my opinion it is something different especially in languages like java as the first is subjective / variable (I decide how to call my variables / methods / etc.) and the second one objective / fixed, because you can only call methods / etc. that are defined for this class / object /...

Inline rename:

Code completion (auto-selection):

Code completion (manual selection):


It would be great, if we would have some control / settings to configure how these two types of dialog behave - ie. let me disable auto suggestions only for inline renaming or something. Please let me know, if the screenshots above look different in your IDEA and it's a local bug in my setup. Thanks!


Hello Philipp,

Can you please clarify why do you want the completion at inline rename to be disabled? Thank you


Hi Olga,

Ideally I would be able to disable the behaviour "Use first suggestion for inline rename automatically" (on Enter key) as a checkbox in the settings.

Like the screenshots above show, the behaviour is different to the regular code completion - it should at least mark the line (= color the background) it will insert. In my opinion, the current behaviour is misleading as it seems the suggestions would be optional (to select with arrows keys or mouse), but they are not - first line is inserted although it's not properly indicated.


Philipp, the behaviour should be as following:

- when you perform the inline renaming, the possible variants to rename are suggested in the completion list, variants are changed as you type;

- you may select the suitable variant from the list by pressing up and down arrows;

- when you press "Enter" without moving arrows up and down, the currently typed variant should be selected as variable name. 

In case your behaviour is different and "not selected" variant from the list, not the one that you manually typed, is used as the variable name when you press "Enter", please share the code sample where the issue is reproduced for you. Thank you 




"- when you press "Enter" without moving arrows up and down, the currently typed variant should be selected as variable name. "

That is not how it behaves for me, "Enter" inserts the first suggestion without it being marked or selected. Only when I press "ESC" to make the suggestion disappear and then "Enter" I get my typed text.

You should be able to reproduce it in any java code, when inline renaming a local variable, class field or method parameter and any suggestion pops up - just stay "inside" the suggestion range and press "Enter" before the written name matches the suggestion completely. If it's not taking the first suggestion, then there's something wrong with my IDEA installation. Please get back to me if you still can't reproduce it, then I'll try to send an example.



Philipp, the behaviour that you describe looks like the bug. Please disable all custom plugins and check if the issue is still reproduced for you. If yes, please create an issue at YouTrack: https://youtrack.jetbrains.com/issues attaching idea.log (Help | Show log in Finder) file to it. Thank you 


Hi Olga, I tried it yesterday on a fresh IDEA install and it behaved the way you describe! I never thought such a case could be changed by a plugin or something else... I will now look for the plugin causing this problem, sorry for the mixup and thanks you both for your patience and help! 



Thank you for checking and letting us know it works know as expected.


Please sign in to leave a comment.