-
Notifications
You must be signed in to change notification settings - Fork 488
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
Add an option to insert a new line before crully braces #405
Comments
Thanks! Will look into it. |
https://github.com/PoshCode/PowerShellPracticeAndStyle/blob/master/Style%20Guide/Code%20Layout%20and%20Formatting.md#open-braces-on-the-same-line - just sayin'. :-) That said, if we ever get script formatting support we will likely provide both styles of braces: Stroustrup (current snippet style) and Allman. |
After writing PowerShell and TypeScript nonstop for the past week, I'm having a hard time not putting curly braces on the same line in C# code ;) |
Isn't it fun being a polyglot programmer? ;-) Know how many times I've tried to use |
Is this still on the radar? Since version 0.9.0 (January 2017) we have the |
AFAIK VSCode snippets can only be specified in one style. In theory, you "should" be able to get what you want with the settings:
And it does work if you "type" in the code. But for snippet completion, it doesn't seem to "invoke" the "formatOnType" functionality. :-( You can force it by deleting the The underlying issue with snippet completion might be with VSCode itself since the extension will format the script correctly. But it has to be given the signal by VSCode and in the case of snippets, I don't think we are getting that "format" signal. FYI, I submitted an issue on VSCode - microsoft/vscode#28006 Maybe there's something we're not doing right in the extension (or with snippets). Let's see what we find out. |
Thanks for filing that! I'm also wonder if I didn't set something up right, hopefully they'll be able to tell us. |
I guess this one has been forgotten about, therefore, I hope this useless comment bumps it back up on to your radar. |
This setting should do what you want:
|
@chantisnake @arcotek-ltd thanks for bringing up this issue, does that setting: |
Unfortunately, the setting does not have the desired effect: This is what I was hoping for:
Thanks |
Try executing the document format command (Alt+Shift+f) after the snippet has been expanded/pasted. The snippets can only be in one brace style. I think there might also be a VSCode to format on type but be aware the performance of the extension might not support that setting very well. |
Oooh. Alt+Shift+f worked. Thank you. Maybe I'll change the shortcut sequence to something simple. I don't know how the snippets work, but I find it strange that they're formatted in that way, especially if one cannot change it (easily). Am I not writing my code in the correct way? |
The snippets are formatted in a snippets file in a single form. The form chosen is what you see. For folks that prefer different formatting, they can use the code formatting settings to adjust the code to their desired code style. Unfortunately, this is a no-win situation. Whatever form you pick for the snippet, some users are not going to like it. |
How does other IDE/vscode plugin dealt with this issue? This seems like a very common issue. |
Another option is to write custom snippet settings i.e. something like
To your powershell.json snippets file. |
This seems like a missing feature in VSCode. @chantisnake Maybe you should submit a suggestion to the VSCode repo that there should be a VSCode option to apply selection formatting to a snippet as it is placed in the document. I tried enabling |
Please fill in these details so that we can help you!
System Details
$PSVersionTable
:Issue Description
Is it possible for an option to put a new line before curly braces (like
"javascript.format.placeOpenBraceOnNewLineForFunctions": true
)for regular coding
will turn to
for snippet
will give
instead of
The text was updated successfully, but these errors were encountered: