dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.88k stars 676 forks source link

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

Open sr229 opened 7 years ago

sr229 commented 7 years ago

Repost on a closed issue in https://github.com/Microsoft/vscode/issues/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 commented 7 years ago

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 commented 7 years ago

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 commented 6 years ago

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

xky0007 commented 5 years ago

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

DanJ210 commented 5 years ago

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 commented 4 years ago

This small thing is making me considering going back to VS

Ashen-Vaults commented 4 years ago

Any updates on this?

jrovny commented 4 years ago

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 commented 4 years ago

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

pengshao commented 4 years ago

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 commented 4 years ago

I understand the frustration but this is blocked by an issue in VS Code https://github.com/Microsoft/vscode/issues/40235

pengshao commented 4 years ago

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

binn commented 4 years ago

and instead they're trying to figure out how to replace the term master with something that won't offend people of color, and any other similar derogatory terms that have nothing to do with their history in the context of programming but oh well, variable and project names are more important than functionality ---- On Wed, 17 Jun 2020 13:12:32 -0500 notifications@github.com wrote ---- Thanks filipw. It is really sad that such a simple bug is taking them this long to respond.

—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.

vcipriani commented 4 years ago

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 - https://github.com/microsoft/vscode/issues/40235

sr229 commented 4 years ago

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

sr229 commented 4 years ago

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

gabrieldechichi commented 3 years ago

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

gabrieldechichi commented 3 years ago

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 commented 2 years ago

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

AjayChambers commented 2 years ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 2 months ago

Any updates on this?

Benny1007 commented 2 months ago

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