不要移动到新创建的方法/类/接口

发布于 2024-11-26 04:37:01 字数 251 浏览 2 评论 0原文

使用灯泡操作创建新创建的类、方法等时,Resharper 会自动移动到该类、方法等。例如,如果我在对象上使用不存在的方法,Resharper 将为我提供创建该方法的可能性。当它完成时,它会自动打开代码文件并移至新生成的方法。

当以 TDD 方式创建单元测试时,或者只是在实现一个需要另一个尚不存在的类的类时,这种跳转到另一个地方会减慢我的编码速度并打断我。我可以将 Reshaper 配置为不切换吗?此行为类似于 Visual Studio 智能标记,也允许创建方法存根。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

迎风吟唱 2024-12-03 04:37:01

据我所知,您无法将 ReSharper 配置为不切换。

其背后的原因是,您需要在 ReSharper 生成代码时部署的模板中选择占位符的值,有时您还可以使用某些代码完成选项(例如,当您生成属性时,您可以选择自动实现它,或创建支持字段。)

您可以做的是使用 ReSharper 导航操作返回到最后的代码位置:

  • 导航到最近的编辑(IntelliJ 中的 Ctrl+Shift+Alt+Backspace
    keymap) 为您提供最近编辑的列表,供您选择
  • 导航到上一个编辑 (Ctrl+Shift+Backspace) 让您直接访问
    之前的代码编辑位置

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
·深蓝 2024-12-03 04:37:01

免责声明:我知道这不是一个理想的答案,但这是我解决此问题的方法。

内置的 Ctrl+. Visual Studio 中内置的功能在存根字段和属性方面做得非常好,并且没有导航到生成的代码的副作用。

请注意,我不允许 Resharper 更改 Visual Studio 中的键盘快捷键,并且我自己映射 Alt+Enter。对于那些使用其他键盘映射选项的人,您可能会发现 Ctrl+.已被 Resharper 超越,但我自己还没有尝试过。如果是这样,您始终可以映射标准 Ctrl+。为此目的,从 Visual Studio 的功能到其他一些访问它的快捷方式。

我希望 JetBrains 能够关注这些问题。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文