From 41bac3da7badc42810e790797e621fb7a63408fa Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 29 Mar 2025 21:36:58 -0500 Subject: [PATCH] more attempts --- protoReformat.go | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/protoReformat.go b/protoReformat.go index f6fc96b..2732522 100644 --- a/protoReformat.go +++ b/protoReformat.go @@ -342,10 +342,12 @@ func formatEnum(curmsg *FormatMsg) []string { if argv.Debug { header := fmt.Sprintf("%s%s // enum2 depth=%d", curmsg.padBase(), curmsg.Header, curmsg.Depth) newmsg = append(newmsg, header) - header = fmt.Sprintf("//%s//%s// enum2 depth=%d", curmsg.padding(2), curmsg.Header, curmsg.Depth) - newmsg = append(newmsg, header) - header = fmt.Sprintf("// %s", curmsg.Header) - newmsg = append(newmsg, header) + /* + header = fmt.Sprintf("//%s//%s// enum2 depth=%d", curmsg.padding(2), curmsg.Header, curmsg.Depth) + newmsg = append(newmsg, header) + header = fmt.Sprintf("// %s", curmsg.Header) + newmsg = append(newmsg, header) + */ } else { header := fmt.Sprintf("%s%s", curmsg.padBase(), curmsg.Header) newmsg = append(newmsg, header) @@ -411,7 +413,16 @@ func formatMessage(curmsg *FormatMsg) []string { var newmsg []string // add the notes & comments before the header - newmsg = append(newmsg, strings.TrimSpace(strings.Join(curmsg.Notes, "\n"))) + // newmsg = append(newmsg, strings.TrimSpace(strings.Join(curmsg.Notes, "\n"))) + for _, line := range strings.Split(strings.TrimSpace(strings.Join(curmsg.Notes, "\n")), "\n") { + if argv.Debug { + footer := fmt.Sprintf("%s%s // msg notes footer depth=%d", curmsg.padBase(), line, curmsg.Depth) + newmsg = append(newmsg, footer) + } else { + footer := fmt.Sprintf("%s%s", curmsg.padBase(), line) + newmsg = append(newmsg, footer) + } + } if curmsg.Header != "" { var line string @@ -453,7 +464,12 @@ func formatMessage(curmsg *FormatMsg) []string { case FormatMsg_ENUM: for _, line := range formatEnum(msg) { // line = fmt.Sprintf("%s%s", curmsg.pad(), line) - newmsg = append(newmsg, line) + line = strings.TrimSpace(line) + if argv.Debug { + line = fmt.Sprintf("%s%s // msg depth=%d", msg.padBase(), line, msg.Depth) + } else { + line = fmt.Sprintf("%s%s", msg.padBase(), line) + } } case FormatMsg_MESSAGE: for _, line := range msg.format() {