From 520ed714a3ee050628d84163e33ba41af4f02d5f Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 4 Oct 2026 22:49:09 +0200 Subject: [PATCH 1/2] Preserve indentation after a single-line import block SingleLineAfterImports rewrote the whitespace after the last import to a bare "\n\n", dropping the indentation of the following line, so a class inside a braced namespace de-indented to column 0. Keep the import line's own indent after the blank line and leave a whitespace that already holds one blank line untouched, matching php-cs-fixer. --- blink/internal/fixer/rules/imports.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) 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 From 81615a7ec3bed13e8176e1f8df7a52cbc8b210c5 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Sun, 4 Oct 2026 22:50:37 +0200 Subject: [PATCH 2/2] Cover braced-namespace import indent; ratchet gate to 0.8% Unit-test SingleLineAfterImports preserving the following line's indent inside a braced namespace, and lower MAX_DIFF_PERCENT to 0.8 (actual 0.795%). --- .github/workflows/blink_parity_mautic.yaml | 2 +- blink/internal/fixer/rules/rules_test.go | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) 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/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 := "