diff options
| author | Matias Fernandez <matiasfmolinari@gmail.com> | 2024-04-17 22:54:30 -0400 |
|---|---|---|
| committer | Matias Fernandez <matiasfmolinari@gmail.com> | 2024-04-17 22:54:30 -0400 |
| commit | e296b050eeca33ef44eb71e00532a8f2f971cb01 (patch) | |
| tree | 5f40c2d755e4c41ba6588374173ad2ca9e1a88d9 /core | |
| parent | 9bbe26f80f0e9ca574544aeda5913ebd96886424 (diff) | |
fix #soa '%#v' formatting
Diffstat (limited to 'core')
| -rw-r--r-- | core/fmt/fmt.odin | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/core/fmt/fmt.odin b/core/fmt/fmt.odin index d3b9d7d69..7f432a6be 100644 --- a/core/fmt/fmt.odin +++ b/core/fmt/fmt.odin @@ -1900,7 +1900,7 @@ fmt_struct :: proc(fi: ^Info, v: any, the_verb: rune, info: runtime.Type_Info_St // fi.hash = false; fi.indent += 1 - if hash { + if !is_soa && hash { io.write_byte(fi.writer, '\n', &fi.n) } defer { @@ -1934,6 +1934,9 @@ fmt_struct :: proc(fi: ^Info, v: any, the_verb: rune, info: runtime.Type_Info_St n = uintptr((^int)(uintptr(v.data) + info.offsets[actual_field_count])^) } + if hash && n > 0 { + io.write_byte(fi.writer, '\n', &fi.n) + } for index in 0..<n { if !hash && index > 0 { io.write_string(fi.writer, ", ", &fi.n) } @@ -1942,9 +1945,23 @@ fmt_struct :: proc(fi: ^Info, v: any, the_verb: rune, info: runtime.Type_Info_St if !hash && field_count > 0 { io.write_string(fi.writer, ", ", &fi.n) } + if hash { + fi.indent -= 1 + fmt_write_indent(fi) + fi.indent += 1 + } io.write_string(fi.writer, base_type_name, &fi.n) io.write_byte(fi.writer, '{', &fi.n) - defer io.write_byte(fi.writer, '}', &fi.n) + if hash { io.write_byte(fi.writer, '\n', &fi.n) } + defer { + if hash { + fi.indent -= 1 + fmt_write_indent(fi) + fi.indent += 1 + } + io.write_byte(fi.writer, '}', &fi.n) + if hash { io.write_string(fi.writer, ",\n", &fi.n) } + } fi.record_level += 1 defer fi.record_level -= 1 |