From fe205da68c81356caf901ce5f487c0baa37c55bc Mon Sep 17 00:00:00 2001
From: apstndb <803393+apstndb@users.noreply.github.com>
Date: Wed, 27 Nov 2024 21:12:23 +0900
Subject: [PATCH] Fix omitEmpty is not propagated (#90)

* Fix omitEmpty is not propagated

* Fix test case
---
 pp_test.go | 8 ++++++--
 printer.go | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/pp_test.go b/pp_test.go
index 6104025..2a22b8e 100644
--- a/pp_test.go
+++ b/pp_test.go
@@ -162,7 +162,11 @@ func TestStructPrintingWithTags(t *testing.T) {
 }
 
 func TestStructPrintingWithOmitEmpty(t *testing.T) {
-	type Bar struct{ StringField string }
+	type Bar struct {
+		StringField string
+		IntField    int
+	}
+
 	type Foo struct {
 		StringField string
 		StringPtr   *string
@@ -182,7 +186,7 @@ func TestStructPrintingWithOmitEmpty(t *testing.T) {
 		want               string
 	}{
 		{
-			name: "all set",
+			name: "set",
 			foo: Foo{
 				StringField: "foo",
 				StringPtr:   &stringVal,
diff --git a/printer.go b/printer.go
index ef3c889..6f1214c 100644
--- a/printer.go
+++ b/printer.go
@@ -477,7 +477,7 @@ func (p *printer) colorize(text string, color uint16) string {
 }
 
 func (p *printer) format(object interface{}) string {
-	pp := newPrinter(object, p.currentScheme, p.maxDepth, p.coloringEnabled, p.decimalUint, p.exportedOnly, p.thousandsSeparator, false)
+	pp := newPrinter(object, p.currentScheme, p.maxDepth, p.coloringEnabled, p.decimalUint, p.exportedOnly, p.thousandsSeparator, p.omitEmpty)
 	pp.depth = p.depth
 	pp.visited = p.visited
 	if value, ok := object.(reflect.Value); ok {