You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched all issues to ensure it has not already been reported.
Summary
When a line ends in an equal sign, I would like the formatting of the next line to be automatically indented. This would help make it clear that the next line is part of the assignment and not the start of a new code statement. This would also allow it to match the behaviour used when a line ends with the pipe character, since it too is a continuation of a code statement, and would match the default behaviour of other languages, such as C# in Visual Studio.
For example, when using the VS Code setting powershell.codeFormatting.pipelineIndentationStyle = IncreaseIndentationForFirstPipeline, the code is currently formatted like this:
$result=Get-Process|Select-Object-First 1
I would prefer = to follow the same rules as | and have the code formatted like this:
$result=Get-Process|Select-Object-First 1
In this small example it may look silly to not just do:
$result=Get-Process|Select-Object-First 1
However, sometimes with fully qualified namespaces and descriptive variable names, the left-side of the equal operator may get very lengthy, such as:
The current formatting makes it easy to overlook that the results returned from Get-CustomersFromCmdletWithAVeryLongName are being saved in a variable.
Proposed Design
No response
The text was updated successfully, but these errors were encountered:
Looking at some other formatting requests, it looks like it is PSScriptAnalyzer that handles all of the code formatting, so I have moved this request to the PSScriptAnalyzer repo here.
Prerequisites
Summary
When a line ends in an equal sign, I would like the formatting of the next line to be automatically indented. This would help make it clear that the next line is part of the assignment and not the start of a new code statement. This would also allow it to match the behaviour used when a line ends with the pipe character, since it too is a continuation of a code statement, and would match the default behaviour of other languages, such as C# in Visual Studio.
For example, when using the VS Code setting
powershell.codeFormatting.pipelineIndentationStyle
=IncreaseIndentationForFirstPipeline
, the code is currently formatted like this:I would prefer
=
to follow the same rules as|
and have the code formatted like this:In this small example it may look silly to not just do:
However, sometimes with fully qualified namespaces and descriptive variable names, the left-side of the equal operator may get very lengthy, such as:
This would look much better and prevent horizontal scrolling as:
Currently, VS Code formats the code like this:
The current formatting makes it easy to overlook that the results returned from Get-CustomersFromCmdletWithAVeryLongName are being saved in a variable.
Proposed Design
No response
The text was updated successfully, but these errors were encountered: