Search code examples
c#.netvisual-studioresharperresharper-6.0

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.


Solution

  • 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