Copilot in Visual Studio Formatting Incorrect (new lines + extra tabs) #60171
-
Select Topic AreaBug BodyHello, In Visual Studio 17.6.4 using Copilot 1.94.0.0, any code (C#) that is automatically inserted is never formatted correctly, it will insert extra tabs and new lines. Testing this in Visual Code behaves as expected, so it seems to be a bug that some people are still experiencing. See the suggestion vs the inserted code. This is also happening for my other team members. |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 16 replies
-
This has also been plaguing me ever since I started using GitHub Copilot with Visual Studio 2022 and it still and issue for me as well. I hope this gets fixed soon as it is quite inefficient. |
Beta Was this translation helpful? Give feedback.
-
Here's an example from VS 2022 version 17.6.5, GitHub Copilot agent version 1.94.220: It appears that Visual Studio accepts the Enter key and indents the next line. Then CoPilot suggests further indentation, assuming that the line was not already indented. |
Beta Was this translation helpful? Give feedback.
-
I'm also experiencing this bug, with the exact behavior described by OP; the suggestion is formatted just fine, but once it's applied then it becomes a disaster. With this bug, many suggestions that could have saved time are now affecting my flow because I have to go back and untangle an indentation hell. It would be awesome if this got some attention, because it really makes using the product feel like a poor experience. |
Beta Was this translation helpful? Give feedback.
-
I was experiencing this for quite a while, also. As is the case with a lot of current issues around AI, I was able to resolve this issue by just tweaking my prompt to say things like "GENERATE THIS CODE FROM THIS POINT FORWARD" or "Replace these contents -- DO NOT INSERT CODE HERE". |
Beta Was this translation helpful? Give feedback.
-
As far as I can tell this happens because when you hit Enter in Visual Studio, the indentation doesn't actually exist until you type something. So the cursor is not really where it it's shown at. If you hit space then backspace, it creates the indentation, and the suggestion goes where it's supposed to. No idea if this is a VS issue or a Copilot issue, but I'd imagine VS is the real culprit here. |
Beta Was this translation helpful? Give feedback.
-
Same issue here using it to create function documentation. Even changed to right arrow to see if it fixes the issue. Using Visual Studio Community 17.8.1, Copilot 1.137.0.0 |
Beta Was this translation helpful? Give feedback.
-
With latest update it still happens It doesn't like constructors |
Beta Was this translation helpful? Give feedback.
-
I am also still experiencing this issue on Version 17.9.7 |
Beta Was this translation helpful? Give feedback.
-
This has been fixed in Version 17.10, which is now available. Please update to the latest version to take advantage of this fix. |
Beta Was this translation helpful? Give feedback.
Tracking the fix here: https://developercommunity.visualstudio.com/t/Extra-spaces-before-the-method-parameter/10517858