Fix flaky tab writing behavior using text/tabwriter #25
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Alternative implementation to #19
Background
This prototype addresses the flaky tab writing issues caused by relying on a regular os.File writer along with our existing tab-based formatting. The output is now handled by a
tabwriter.Writer
from thetext/tabwriter
package, which integrates with the existing view/stream mechanism as it implements theio.Writer
interface too. Thetabwriter
package acts as a write filter, translating tabbed input columns into proper aligned text for consistent and reliable formatting.Debugging
In 1727fac, I added support for debugging the tab writer. When the
debug
flag is set, it prints a vertical bar('|')
between columns after formatting, and any discarded columns appear as zero-width columns("||")
.To be considered
FWIW, it might be worth considering moving the tab writer implementation down into the rendering logic, as this would make sure that consumers (e.g., tests) inherit all the behavior of the tab writer. On the other hand, the rendering logic is designed to support any writer, so this change might compromise that flexibility.