From 8e6b51fa9bef7d528eb13ce97f356542c8071756 Mon Sep 17 00:00:00 2001 From: txtpbfmt team Date: Fri, 23 Aug 2024 01:45:05 -0700 Subject: [PATCH] Incremental improvement to granular disabling directive. PiperOrigin-RevId: 666695192 --- parser/parser.go | 2 ++ parser/parser_test.go | 3 +++ 2 files changed, 5 insertions(+) diff --git a/parser/parser.go b/parser/parser.go index ac2c77d..5c9ebc7 100644 --- a/parser/parser.go +++ b/parser/parser.go @@ -876,6 +876,8 @@ func (p *parser) readFormatterDisabledBlock() (string, error) { if !p.consume('\n') { return "", fmt.Errorf("txtpbfmt on should be followed by newline at %s", p.errorContext()) } + // Retain up to one blank line. + p.consume('\n') return string(p.in[start:p.index]), nil } } diff --git a/parser/parser_test.go b/parser/parser_test.go index 6fb7e45..9a3fd69 100644 --- a/parser/parser_test.go +++ b/parser/parser_test.go @@ -1476,6 +1476,8 @@ bar { } enabled: {TEMPLATE_plx} # txtpbfmt: on + + } should_format { foo: "bar" @@ -1502,6 +1504,7 @@ bar { } enabled: {TEMPLATE_plx} # txtpbfmt: on + } should_format { foo: "bar"