diff --git a/.github/workflows/blink_parity_mautic.yaml b/.github/workflows/blink_parity_mautic.yaml index 0ad8867f88..a9c2f04b13 100644 --- a/.github/workflows/blink_parity_mautic.yaml +++ b/.github/workflows/blink_parity_mautic.yaml @@ -95,7 +95,7 @@ jobs: - name: Compare the two trees run: | # ratchet gate: fail once the differing share crosses this; lower it as parity improves - MAX_DIFF_PERCENT=1.0 + MAX_DIFF_PERCENT=0.8 total=0 differ=0 differing_files="" diff --git a/blink/internal/fixer/rules/imports.go b/blink/internal/fixer/rules/imports.go index f733856d12..f05fa94954 100644 --- a/blink/internal/fixer/rules/imports.go +++ b/blink/internal/fixer/rules/imports.go @@ -215,10 +215,18 @@ func (SingleLineAfterImports) Fix(s *tokens.Stream) bool { if next.Kind == token.Punct && next.Value == "}" { continue } - if s.At(semi+1).Kind == token.Whitespace && - hasNewline(s.At(semi+1).Value) && s.At(semi+1).Value != "\n\n" { - s.SetValue(semi+1, "\n\n") - changed = true + ws := s.At(semi + 1) + if ws.Kind == token.Whitespace && hasNewline(ws.Value) { + // preserve the import line's own indentation after the blank line, so a + // braced-namespace body keeps its level; a whitespace that already holds + // exactly one blank line (two newlines) is left untouched, as php-cs-fixer + if strings.Count(ws.Value, "\n") != 2 { + target := "\n\n" + indentBefore(s, i) + if ws.Value != target { + s.SetValue(semi+1, target) + changed = true + } + } } } return changed diff --git a/blink/internal/fixer/rules/rules_test.go b/blink/internal/fixer/rules/rules_test.go index 465d1eab0f..7fa2df6fe9 100644 --- a/blink/internal/fixer/rules/rules_test.go +++ b/blink/internal/fixer/rules/rules_test.go @@ -346,6 +346,17 @@ func TestSingleLineAfterImports(t *testing.T) { if want := "