miller/pkg/output
John Kerl a723f6cdaa
Fix PPRINT alignment with multi-character OFS (#1819) (#2063)
* Fix column alignment for wide and combining Unicode chars (#1520, #379)

PPRINT, markdown-aligned, and XTAB writers measured column widths with
utf8.RuneCountInString, which counts codepoints rather than terminal
display columns. East-Asian fullwidth characters (counted as 1 but
displayed as 2) and zero-width combining marks (counted as 1 but
displayed as 0) both caused misalignment.

Add lib.DisplayWidth wrapping uniseg.StringWidth, and use it from the
three writers. The XTAB right-aligned path also drops fmt.Sprintf with
%*s since Go's %*s pads by rune count too.

UTF8Strlen is unchanged so DSL strlen semantics are preserved.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Fix PPRINT alignment with multi-character OFS (#1819)

Previously, writePadding repeated the OFS string for each padding slot, so
non-space or multi-character OFS values produced misaligned columns and
leaked the separator into padding (e.g. --ofs=XY yielded aXYXYXYXYb).

Pad with spaces instead, leaving OFS to act only as the column separator.
The default single-space OFS is unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Use non-space multi-char OFS in test 0021 for Windows portability

PowerShell collapses single-quoted '  ' in command lines, which broke
the test on the windows-latest CI runner. Switch to --ofs XY, which
exercises the same multi-character padding code path without shell
quoting hazards.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-17 12:45:49 -04:00
..
channel_writer.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
doc.go Export library code in pkg/ (#1391) 2023-09-10 17:15:13 -04:00
file_output_handlers.go Some fixes for staticcheck (#2006) 2026-03-03 09:27:03 -05:00
README.md Export library code in pkg/ (#1391) 2023-09-10 17:15:13 -04:00
record_writer.go The package version must match the major tag version (#1654) 2024-09-20 12:10:11 -04:00
record_writer_csv.go Resolve a few to-do comments in the source code (#1951) 2026-02-01 18:14:20 -05:00
record_writer_csv_colorizer.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
record_writer_csvlite.go The package version must match the major tag version (#1654) 2024-09-20 12:10:11 -04:00
record_writer_dcf.go Some fixes for staticcheck (#2006) 2026-03-03 09:27:03 -05:00
record_writer_dkvp.go The package version must match the major tag version (#1654) 2024-09-20 12:10:11 -04:00
record_writer_dkvpx.go Add DKVPX file format (#2002) 2026-03-02 22:35:08 -05:00
record_writer_factory.go Add DKVPX file format (#2002) 2026-03-02 22:35:08 -05:00
record_writer_json_jsonl.go Multiple style updates (#1974) 2026-02-16 15:49:21 -05:00
record_writer_markdown.go Fix column alignment for wide and combining Unicode chars (#1520, #379) (#2061) 2026-05-17 12:12:54 -04:00
record_writer_nidx.go The package version must match the major tag version (#1654) 2024-09-20 12:10:11 -04:00
record_writer_pprint.go Fix PPRINT alignment with multi-character OFS (#1819) (#2063) 2026-05-17 12:45:49 -04:00
record_writer_tsv.go The package version must match the major tag version (#1654) 2024-09-20 12:10:11 -04:00
record_writer_xtab.go Fix column alignment for wide and combining Unicode chars (#1520, #379) (#2061) 2026-05-17 12:12:54 -04:00
record_writer_yaml.go fix: preserve key order in YAML output (#2034) 2026-04-12 09:43:09 -04:00

Logic for formatting output records as strings to standard output.

There is one record-writer type per supported output file format, and a factory method.