When a line ends in an operator, automatically indent the next line since it is part of the same code statement
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 4/5
- Tempo estimado
- 3-5 dias
- Facilidade para iniciantes
- 35/100
- Tipo de issue
- Funcionalidade
- Clareza
- Razoavelmente clara
- Status de atividade
- Estagnada
- Stack de tecnologia
- powershell
- Domínio
- tooling
Direção de pesquisa
Comece rastreando o comportamento existente de indentação do pipe | no formatter do PSScriptAnalyzer e como os operadores de continuação de linha são classificados. Estenda as mesmas regras a operadores como =, + e - e, em seguida, verifique a saída formatada em relação aos exemplos e ao comportamento existente do pipe.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Summary of the new feature
As a user, when a line ends in a line continuation operator (=, +, -, etc.), I would like the next line to be indented so that it is clear both lines are part of the same statement, and that the 2nd line is not the start of a new code statement. This behaviour is already implemented for the pipe | operator, and it would be great if the other operators followed the same rules. This behaviour would also match the default behaviour of other languages, such as C# in Visual Studio. In VS Code, this behaviour is controlled for the pipe operator with the powershell.codeFormatting.pipelineIndentationStyle setting.
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:
[System.Collections.ArrayList] $listOfCustomersWithValidDriversLicenses = Get-CustomersFromCmdletWithAVeryLongName -Country Canada -AreaCode 123
This would look much better and prevent horizontal scrolling as:
[System.Collections.ArrayList] $listOfCustomersWithValidDriversLicenses =
Get-CustomersFromCmdletWithAVeryLongName -Country Canada -AreaCode 123
Currently, VS Code formats the code like this:
[System.Collections.ArrayList] $listOfCustomersWithValidDriversLicenses =
Get-CustomersFromCmdletWithAVeryLongName -Country Canada -AreaCode 123
The current formatting makes it easy to overlook that the results returned from Get-CustomersFromCmdletWithAVeryLongName are being saved in a variable.
The example above is for the = operator, but I think it would make sense to do the same thing for +, -, and any other line continuation operators (i.e. that don't require a backtick ` to have the statement continue onto the next line).
Aside: I originally posted this issue in the vscode-powershell repo here, but I think this is the proper place for this feature request.
What is the latest version of PSScriptAnalyzer at the point of writing
The latest stable version of PSScriptAnalyzer is currently v1.22.0.
- Linguagem predominante
- C#
- Estrelas
- 2.2k
- Forks
- 415
- Merge médio
- 13h 1min
- PRs com merge (30d)
- 2
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de PowerShell/PSScriptAnalyzer
-
Up-for-Grabs
Dificuldade 1/5 1-3 horas Facilidade para iniciantes 78/100
PowerShell/PSScriptAnalyzer#2213 · 2 comentários ·
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 72/100
PowerShell/PSScriptAnalyzer#2217 · 1 comentário ·
-
PSUseConsistentIndentation double-indents attribute bodies that open a scriptblock (`[Attr({ … })]`) Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 70/100
PowerShell/PSScriptAnalyzer#2216 · 2 comentários ·
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 68/100
PowerShell/PSScriptAnalyzer#2211 ·
-
`PSPlaceOpenBrace` and `PSPlaceCloseBrace` leave trailing whitespace when expanding one-line blocks Aberta
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 70/100
PowerShell/PSScriptAnalyzer#2210 ·
Todas as issues de PowerShell/PSScriptAnalyzer
Issues semelhantes
-
Documentation
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
cake-build/cake#5024 ·
-
Frontend status/draft TechnicalDebt
Dificuldade 2/5 1-2 dias Facilidade para iniciantes 75/100
Altinn/altinn-auth#4143 ·
-
.NET Flaky Test Testing Tests
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 84/100
getsentry/sentry-dotnet#5617 · 1 comentário ·
-
:watch: Not Triaged dotnet-fsharp/svc
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 90/100
-
Client customer-reported needs-team-attention question Service Attention WebPubSub
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
Azure/azure-sdk-for-net#63292 · 3 comentários · 1 reação ·