Skip to content

Commit

Permalink
Merge pull request #1 from webrpc/struct_enum_field_fix
Browse files Browse the repository at this point in the history
Formatting of space after dash in fields within structs and enums
  • Loading branch information
david-littlefarmer committed May 10, 2024
2 parents 0a06d1e + e17d144 commit d2f096a
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions formatter/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,16 +143,17 @@ func (f *form) formatLine(line string) (string, error) {
f.padding = 2
line = reduceSpaces(line)
switch f.topLvlSection {
case sectionStruct, sectionEnum:
case sectionEnum:
s, c := parseAndDivideInlineComment(line)
p := strings.TrimSpace(strings.Split(strings.TrimSpace(s), "-")[1])
line = fmt.Sprintf("%s- %s", strings.Repeat(" ", f.padding), p)
line = c.appendInlineComment(line)
case sectionStruct:
s, c := parseAndDivideInlineComment(line)
parts := strings.Split(s, ":")
if len(parts) == 2 {
p1 := strings.TrimSpace(parts[0])
p2 := strings.TrimSpace(parts[1])
s = fmt.Sprintf("%s: %s", p1, p2)
}

line = fmt.Sprintf("%s%s", strings.Repeat(" ", f.padding), s)
p1 := strings.TrimSpace(strings.Split(strings.TrimSpace(parts[0]), "-")[1])
p2 := strings.TrimSpace(parts[1])
line = fmt.Sprintf("%s- %s: %s", strings.Repeat(" ", f.padding), p1, p2)
line = c.appendInlineComment(line)
case sectionService:
s, c := parseAndDivideInlineComment(line)
Expand Down

0 comments on commit d2f096a

Please sign in to comment.