Conflict between ReSharper and GitHub Copilot Auto-completions both using Tab at the same time
Asked Answered
P

2

7

I'm encountering an issue when using both ReSharper and GitHub Copilot in Visual Studio 2022. Both of these tools offer code suggestions, which is incredibly helpful, but they sometimes clash, leading to code that is unusable.

  • When I start typing code, for instance, if I input the letter "i," ReSharper immediately suggests an "if" statement. On the other hand, GitHub Copilot, provides a complete statement that fits the context of what i am trying to do, and both are shown at the same time; ReSharper with its context menu, and Copilot with its in-line suggestion.

ReSharper suggestion:

if (expr)
{
    
}

Where it moves the caret into the expr, in order to let me fill in the expression.

Copilot suggestion:

if (Logger.IsDebugEnabled)
    Logger.Info($"GetNearestClimate returned: {climateData}");
  • To address this issue and prioritize GitHub Copilot's suggestions, I've already enabled the setting "Disable ReSharper automatic completion while GitHub Copilot suggestion is shown." My expectation is that, when I press the "Tab" key to accept GitHub Copilot's suggestion, it should be integrated into my code, and the ReSharper menu should close and not be used.

However, the problem arises when I press "Tab." Surprisingly, both ReSharper and GitHub Copilot simultaneously accept the suggestion. ReSharper follows its template for "if" statements, while GitHub Copilot appends some of its code, resulting in a tangled mess of unusable and conflicting code.

if (expr)
{
    
}                    Logger.Info($"GetNearestClimate returned: {climateData}");

What can I do to make sure that GitHub Copilot's suggestions take precedence over ReSharper's in these situations. How can I manage this conflict and ensure that GitHub Copilot's code suggestions are consistently used while still benefiting from ReSharper's valuable features, such as the entire context menu itself?

Preferably, Copilot would consume whenever I hit "Tab", while ReSharper would consume whenever I hit space or enter, as it already does - so just disabling the "Tab" functionality for ReSharper, however I was unsuccessful in finding such an option.

I have already looked into the settings and tried to both enable and disable the "Disable ReSharper automatic completion while GitHub Copilot suggestion is shown." option.

I have also tried looking into whether it is possible to disable the Tab key for ReSharper, but to no avail.

I would greatly appreciate any insights, tips, or workarounds without disabling features to address this issue. Thank you for your assistance.

Pentup answered 9/11, 2023 at 10:31 Comment(4)
Would it be an option to activate CoPilot only "on demand"? It obviously suggests sub par quality code, so you may want to use it more aimed, anyway?Disbud
@Disbud The suggestion from Copilot is exactly what i wanted in the situation, so it is not ideal having to turn it on and off all the time. It is also a bit more annoying to change it to a non-automatic suggestion, as it is not due to the code being difficult to write, it is simply to save some time with writing simple code.Pentup
Devs have it so easy these days, writing code without typing (or thinking in some cases), back in my day we had to type everything out character by character...Ahearn
Back in the day @PiersMyers it would take ten people two weeks (and subsequently back pain), to dig out a basement for one building. Today one man with a machine can do the same within a few days - that way the construction workers could focus on the important things; building cheaper better houses. Why shouldn't this be the case for coders? 25 years ago I would spent five-six hours getting a DB connection up and running pre DOTNET. To day its two keys on a keyboard and then <TAB>. Boom! Then I move on to whats important: Get more done in less time.Chelsiechelsy
J
5

It happens to be a known issue - https://youtrack.jetbrains.com/issue/RSRP-491939. While we are working on the fix, I'd suggest switching from ReSharper completion to VS one in ReSharper | Options | Environment | IntelliSense | General.

Judicial answered 10/11, 2023 at 11:40 Comment(0)
P
4

here are some suggestions from GitHub copilot docs

https://github.com/Prajwal270/Github-copilot-docs/blob/main/docs/visualstudio/resharper.md

Pastime answered 5/12, 2023 at 4:34 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.