internal/encoding/text: minor tweak in inserting random whitespace

Simply move logic into similar code block.  Maintains the same logic.

Change-Id: I7b5a3f3d57f6102c7919cdc03dd105f08d21aca3
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/194039
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/internal/encoding/text/encode.go b/internal/encoding/text/encode.go
index 1f49761..8f146ae 100644
--- a/internal/encoding/text/encode.go
+++ b/internal/encoding/text/encode.go
@@ -113,11 +113,11 @@
 		p.out = append(p.out, ':')
 		if len(p.indent) > 0 {
 			p.out = append(p.out, ' ')
-		}
-		// For multi-line output, add a random extra space after key: per message to
-		// make output unstable.
-		if len(p.indent) > 0 && detrand.Bool() {
-			p.out = append(p.out, ' ')
+			// For multi-line output, add a random extra space after key:
+			// to make output unstable.
+			if detrand.Bool() {
+				p.out = append(p.out, ' ')
+			}
 		}
 
 		if err := p.marshalValue(item[1]); err != nil {
@@ -125,11 +125,11 @@
 		}
 		if i < len(items)-1 && len(p.indent) == 0 {
 			p.out = append(p.out, ' ')
-		}
-		// For single-line output, add a random extra space after a field per message to
-		// make output unstable.
-		if len(p.indent) == 0 && detrand.Bool() && i != len(items)-1 {
-			p.out = append(p.out, ' ')
+			// For single-line output, add a random extra space after a field
+			// to make output unstable.
+			if detrand.Bool() {
+				p.out = append(p.out, ' ')
+			}
 		}
 		p.out = append(p.out, p.newline...)
 	}