Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor's Bracket styling C# seems to be only following JavaScript style bracket-styling #1591

Open
sr229 opened this issue Jun 26, 2017 · 24 comments

Comments

@sr229
Copy link

sr229 commented Jun 26, 2017

Repost on a closed issue in microsoft/vscode#29314

Spotted by @binnysenpai

Apparently, the Editor only follow JavaScript-style bracket-styling for the autobracket formatting for C#/C++ files.

video link

Usually in Visual Studio, this would be autoomaticaly formatted by automatically newline the opening bracket and put the statement after the line.

And also it seems not to format automatically this type of statements

video link

Which should look like this

image

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-preview2-003121)

Product Information:
 Version:            1.0.0-preview2-003121
 Commit SHA-1 hash:  1e9d529bc5

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14393
 OS Platform: Windows
 RID:         win10-x64

VS Code version: 1.13.1
C# Extension version: 1.10.0

@DustinCampbell
Copy link
Member

Hi! Thanks for reporting this issue. We'd definitely like to improve formatting in these particular cases to better match Visual Studio's behavior. Note that you can press Alt+Shift+F to format the current document, which should force the proper formatting.

@DanielKorsah
Copy link

DanielKorsah commented Aug 29, 2017

I have the same issue. Upon forcing formatting it works and using formatOnSave it also works. But not using formatOnType. I find myself saving every block or manually fixing it.

@rchande
Copy link

rchande commented Nov 30, 2017

@akshita31 Can you take a look at this one too?

@xky0007
Copy link

xky0007 commented May 5, 2019

Any new solution for this problem? Still have it with 1.19.

@DanJ210
Copy link

DanJ210 commented Nov 15, 2019

I've got this issue also. Only thing that works for me is format on save. Paste doesn't even format. This affects all formatting extensions not just the C# one.

@h4zm1
Copy link

h4zm1 commented Jan 18, 2020

This small thing is making me considering going back to VS

@Ashen-Vaults
Copy link

Any updates on this?

@jrovny
Copy link

jrovny commented Feb 24, 2020

Would like to voice my support for this. That's one of the few things keeping me from going permanent VS Code for C# development.

@sr229
Copy link
Author

sr229 commented Mar 2, 2020

Looks like this is slated for 1.18 so we finally might see this in that release.

@pengshao
Copy link

I am on omnisharp 1.22.1 over vscode 1.46.0 and still seeing this issue. I don't like to be rude but the frustration is unbelievable over such a simple function.

@filipw
Copy link
Contributor

filipw commented Jun 17, 2020

I understand the frustration but this is blocked by an issue in VS Code microsoft/vscode#40235

@pengshao
Copy link

Thanks filipw. It is really sad that such a simple bug is taking them this long to respond.

@binn
Copy link

binn commented Jun 17, 2020 via email

@vcipriani
Copy link

To be fair to the VS code team, no one is giving them any feedback that it is important. If you're interested in getting this resolved, please follow up on the VS Code blocking issue - microsoft/vscode#40235

@sr229
Copy link
Author

sr229 commented Jun 29, 2020

I suggest leaving politics out of this @binn. This does not concern OmniSharp in any way at all.

@sr229
Copy link
Author

sr229 commented Aug 9, 2020

@vcipriani I asked for an update on microsoft/vscode#40235 - is this the only blocker for this feature?

@gabrieldechichi
Copy link

I'm still experiencing this issue. Is there any fix or workaround?

@gabrieldechichi
Copy link

For anyone seeing this in the future. I've found a workaround to automatically place braces on a new line by using keybindgs and snippets. Adding the following to your keybinding.json config should do the trick:

{
        "key": "Shift+[",
        "command": "editor.action.insertSnippet",
        "when": "editorTextFocus",
        "args": {
            "snippet": "\n{\t$0\n}"
        }
}

This is not a perfect solution, as it jumps the line when you type { instead of waiting for you to hit enter, but it's been working quite nicely for me since the combo { + enter does exactly what you would expect in other IDEs like VS (you'll have an open brace in new line, and your cursor in the middle of both braces)

@Benny1007
Copy link

how is this still an issue 5 years later, puts me off using vscode for c# dev

@AjayChambers
Copy link

how is this still an issue 5 years later, puts me off using vscode for c# dev

I don't write C#, but I have wrote Java, C & C++ in the past, and used VSCode, VS 2019/2022 & IntelliJ/CLion and I can say that VS Code has got better, but all of them had a better experience when using a TRUE IDE. Currently I write TypeScript as the primary language for professional projects, and I run it not in the frontend, but with a V8 Runtime, (Node or Deno), and I can say this, VS Code is unrivaled when it comes to web-technologies. Traditional software languages though, your going to get issues like this.

@abhinav-0401
Copy link

I am STILL experiencing this issue, and 2022 has ended. Kinda ridiculous to be honest. It's very off-putting, especially on platforms like Linux where the only other option worth considering is Rider, which is expensive and heavy.

@conlanpatrek
Copy link

conlanpatrek commented Apr 30, 2023

Obligatory 2023 bump. Would love to see this resolved.

Edit: Mac user btw. Can't use visual studio, because the latency in intellisense makes it unusable, as it blocks my input, and I end up constantly waiting a couple of seconds for the editor to catch up to what I've typed. There are other issues but this isn't the place.

I'm doing format on save for now. Best of the bad choices imo.

@B1ack3ye
Copy link

B1ack3ye commented Sep 4, 2024

Any updates on this?

@Benny1007
Copy link

I found an extension that does exactly what I was after, here is the marketplace link: -
https://marketplace.visualstudio.com/items?itemName=Ironcutter24.cscurlyformatter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests