PowerShell / PowerShell/PSScriptAnalyzer
`Invoke-Formatter -Range` silently drops corrections after earlier fixes shift text
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- C#
- Estrelas
- 2.2k
- Forks
- 415
- Merge médio
- 13h 1min
- PRs com merge (30d)
- 2
Descrição
Steps to reproduce
Format only the second line, with the range covering the complete statement:
Invoke-Formatter -ScriptDefinition "if(`$a){'x'}`nif(`$b){'y'}" -Range @(2, 1, 2, 12)
Expected behavior
Every formatting correction within the selected statement should be applied:
if($a){'x'}
if ($b) { 'y' }
Actual behavior
The space before the final } is missing:
if($a){'x'}
if ($b) { 'y'}
The formatter applies fixes iteratively. Earlier corrections make the selected line longer, but later violations are still filtered against the original fixed range coordinates. Once a correction shifts beyond the original range end, it is silently dropped even though it belongs to the statement selected by the caller.
Expected resolution
Track the range through applied edits, or filter corrections once against their original extents, so that a range covering a complete statement formats that statement completely.
Environment data
Reproduced with:
- PSScriptAnalyzer 1.25.0 on PowerShell 7.5.2
- PSScriptAnalyzer built from
mainat PowerShell/PSScriptAnalyzer@4b0117ca7d2887711c9699f467ba7171f8859156 on PowerShell 7.6.4
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.
Direção de pesquisa
Comece pelo ponto de entrada Invoke-Formatter -Range e reproduza o comando fornecido nas versões especificadas do PSScriptAnalyzer. Rastreie como as correções iterativas de formatação são filtradas em relação ao intervalo selecionado e, em seguida, verifique se todas as correções dentro da instrução completa são aplicadas, incluindo o espaço final antes de }.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- powershell
- Domínio
- tooling
- Tipo de issue
- Bug
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Ativa
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 68/100