Daniel Hilgarth
Daniel Hilgarth

Reputation: 174379

Don't move to newly created method/class/interface

Resharper automatically moves to the newly created class, method etc, when creating it using the bulb action. For example, if I use a non-existing method on an object, Resharper provides me with the possibility to create that method. When it does, it automatically opens the code file and moves to the newly generated method.

When creating unit tests in a TDD manner or just when implementing one class that needs another class that doesn't exist yet, this jump to another place slows down my coding and interrupts me. Can I configure Resharper to not switch? This behavior would be similar to the Visual Studio smart tag that also allows to create a method stub.

Upvotes: 3

Views: 208

Answers (2)

jpierson
jpierson

Reputation: 17384

DISCLAIMER: I know this isn't an ideal answer but it is what I do to work around this issue.

The built in Ctrl+. feature built in to Visual Studio does a pretty good job of stubbing fields and properties and doesn't have the side effect of navigating to the generated code.

Note that I do not allow Resharper to change my keyboard shortcuts in Visual Studio and I map Alt+Enter myself. For those that use the other keyboard mapping options you may find that Ctrl+. is overtaken by Resharper but I haven't tried this out myself. If so you could always map the standard Ctrl+. functionality from Visual Studio to some other shortcut to access it for this purpose.

I hope JetBrains is paying attention to these issues.

Upvotes: 1

Jura Gorohovsky
Jura Gorohovsky

Reputation: 10148

As far as I'm aware, you can't configure ReSharper not to switch.

The reason behind this is that you're expected to select values for placeholders in templates that ReSharper deploys when it generates code, and sometimes you can also use certain code completion options (for example, when you generate a property, you have a choice between auto-implementing it, or creating backing fields.)

What you can do is use ReSharper navigation actions to get back to the last code position:

  • Navigate to Recent Edits (Ctrl+Shift+Alt+Backspace in IntelliJ keymap) gets you a list of recent edits to choose from
  • Navigate to Previous Edit (Ctrl+Shift+Backspace) gets you directly to the previous code editing location

Upvotes: 3

Related Questions