Please stop deleting my code on auto-complete

Answered

Why does Rider delete code to the right of my cursor when I use auto-complete? I just don't get it.

Take the following line:

In this line, I forgot to get the directory-name from the full filename. So I start typing:

That's good! I want "GetDirectoryName" and hit Tab.

As a result, Rider deletes the code to the right of my cursor:

Why?

I don't get it! 

This happens all the time while coding. And the workaround sucks:

Instead of just hitting Tab, I need to hit Escape, Space, Cursor left, Ctrl+Space and then Tab. And then I need to delete the space again.

What business does the auto-complete have with the code to the right of my cursor?

11
18 comments

Hello Andreas,

Thank you for contacting Rider support. It happens because `Tab` key is responsible for `Choose Lookup Item Replace`. Also, there is a different action `Choose Lookup Item` which is assigned to `Enter`. 
I suggest the following solutions:

  1. To use `Enter` for autocomplete instead of `Tab` and use `Tab` if only you want to replace the code on the right.
  2. To remap `Tab` to `Choose Lookup Item` action from settings:
  • Find `File | Settings | Keymap | Editor Actions | Choose Lookup Item Replace` action (You can type `Choose Lookup` into search textbox to find it easier);
  • Right-click on it;
  • Select `Remove Tab`;
  • Find `File | Settings | Keymap | Editor Actions | Choose Lookup Item` action;
  • Right-click on it;
  • Select `Add Keyboard Shortcut`;
  • Click `+`;
  • Select `Set Tab` -> `Ok` -> `Keep`;

Hope it helps.

8

Thank you! All (!) members in my team changed the behavior as soon as the read your post. After each one cursed Rider for deleting code on the right side of the cursor.

Who does actually want this kind of behavior on a regular basis?

I think it could be a good idea to change the default-settings.

6

Hello Andreas,

Thank you for your feedback. We will probably change this default behavior for newcomers from Visual Studio. We will need to discuss this with the team.

Have a nice day!

1

Glad I found this. It's one of those things that has ALWAYS annoyed me about Rider, but that I never got round to finding a 'fix' for... until today!

1

Hey! Is it just me or making changes to "Choose Lookup Item" or "Choose Lookup Item Replace" doesn't make a difference? I even restarted Rider after and it still made no difference.

2

Hello Matt,

It is strange. Would you mind sharing the additional information as described below?

  • Enable the Editors, Completion, EditorsDumpAllTypingAndActions trace scenarios via Help | Diagnostic Tools | Choose Trace Scenarios;
  • Reproduce the issue;
  • Collect Rider logs via Help | Collect Logs;
  • Disable the trace scenarios enabled;
  • Upload log archive to the Upload service and let me know the upload id;

Thank you in advance and have a nice day!

0

In case someone arrives here through desperate searching to solve the same issue in ReSharper (since R# and Rider have shared codebase), change the behavior in Options-Environment-Completing Characters. Change Tab Key from Replaces to Inserts.

0

This seems to have no effect even after restarting

0
Hello,

Thank you for contacting Rider Support.

Is it possible to share the code snippet where the issue is reproduced?

Thank you in advance!
0

I read this entire thread and was nodding along with Matt and the gif they posted. I then tried to reproduce it in my currently opened rider, which has an Unreal project loaded, and managed to reproduce it successfully. Not surprising to me since that's the reason I started searching for this support issue.

Since Matt didn't answer after Dmitry Kazantsev asked for trace logs I wanted to produce those trace logs myself. For that, I enabled the 3 suggested trace scenarios, closed my project, opened the LyraStarterGame (official sample project from Epic Games) and tried to reproduce the issue there. I was not able to repro it there! I then opened my other project again and couldn't repro there anymore, either!

It seems to be a sporadic issue and I'm not sure how to reliably reproduce it.

0
Hello Manuel,

As per my testing, this behavior only happens when the Choose Lookup Item Replace action is assigned to the Tab key.
I am glad to know that the issue has gone away. Should you encounter it again, we would appreciate it if you could share the details I requested.

Have a nice day!
0

Glad I found this thread, disappointed I couldn't find a resolution. 

Seems to work fine for a straight method call (can be chained), e.g app.UseAuthentication(), or app.UseAuthentication().UseRouting()… but not for a generic, e.g. .AddScoped<>().

In the following .gif example I first use Tab to make the selection, then Enter (settings for 'Choose Lookup Item Replace' and ‘Choose Lookup Item’ are the default Enter and Tab respectively.

https://imgur.com/ZIXRJSt

Hope this helps.

1

I notice the same thing as Amorgan. In certain circumstances it will erase your type arguments, just as in his gif. You have to use Ctrl-Z to get them back.

Another thing it will do is add <>() when they are already there.

Something.Method<Arg>(arg);

if you try changing the name Method with intellisense it then becomes:

Something.Method2<>()<Arg>(arg);

Or sometimes even:

Something.Method2<>()Method<Arg>(arg);
0

Hello AMorgan NZ ,

Thank you for the gif shared. Would you mind clarifying what the issue you tried to demonstrate?

In your scenario: (| is a caret)

  • You have written .|AddScoped<IUserRepository, UserRepository>();;
  • You invoke completion and select the AddSignature method that has no type arguments (<>) nor method arguments;
  • You press Tab invoking the Choose Lookup Item and Replace action;
  • It replaces .AddScoped<IUserRepository, UserRepository>(); with AddSignature();;

This is by design. If you do not want Rider to replace the text on the right, you can get rid of the Choose Lookup Item and Replace action by assigning Tab and Enter to the Choose Lookup Item action and removing Tab from the Choose Lookup Item and Replace action.

If I misunderstood the problem, please tell me.

0

Hello Dave,

I covered the point with it will erase your type arguments in the message above. If Rider erases your arguments in any other circumstances, please tell me.

Regarding the point that Rider adds <>() when they are already there. 
I reproduced this behavior by pressing Enter (the Choose Lookup Item action) when confirming the completion selection. This is by design. 

That should not happen if you press Tab instead of Enter, having in mind that you choose the signature that has the same number of type and method arguments.

If pressing Tab doesn't solve this problem, I would appreciate it if you could share more detailed steps on how to reproduce the issue.

Have a nice day!

0

I am still seeing it wiping out text that I wish it would keep, and it doesn't matter if I use ‘.’, ‘Tab’, ‘Enter’, or "Ctrl+.'. 

As for adding the <>() all the time, it would be very nice if you added a bit more smarts to that logic, I run into this all the time, and it's very annoying. 

 

1

Hello Tehtarget, thank you for your comment.

I've submitted a new issue to our bug tracker: Completion by "." erases type parameter of static method invocation. Please comment or vote for it to get notifications about status changes. Thank you!

0

Please sign in to leave a comment.