Fix/ansi unicode tables#930
Draft
jonathan-conder wants to merge 2 commits into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses issue #925 (misaligned sdk find output when ANSI-colored Unicode publisher badges are present) by switching table formatting to an ANSI-aware tabwriter and updating several CLI table headers to use escape sequences safely.
Changes:
- Replace usage of the stdlib
text/tabwriterwithgithub.com/juju/ansiterm/tabwriter(usingStripEscape) to keep column alignment correct with ANSI escapes. - Update multiple CLI commands to render table headers with bold escapes without breaking alignment.
- Introduce a
go.modreplaceto a forkedansitermversion (to be finalized before merge).
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| go.mod | Adds github.com/juju/ansiterm and a replace to a forked module revision. |
| go.sum | Records checksums for the newly introduced dependencies (ansiterm fork + transitive deps). |
| docs/coding-style-guide.md | Updates the style guide example to use ansiterm/tabwriter. |
| cmd/workshop/tasks.go | Uses escape-aware bold header formatting for the tasks table. |
| cmd/workshop/sketch.go | Uses escape-aware bold header formatting for sketches table output. |
| cmd/workshop/list.go | Switches to ansiterm/tabwriter and bolds headers; defines ANSI-safe tabWriter(). |
| cmd/workshop/info.go | Switches to ansiterm/tabwriter to keep escape handling consistent in output. |
| cmd/workshop/connections.go | Uses escape-aware bold header formatting for connections table output. |
| cmd/workshop/changes.go | Uses escape-aware bold header formatting for changes table output. |
| cmd/sdk/list.go | Switches to ansiterm/tabwriter and bolds the list header safely. |
| cmd/sdk/info.go | Switches to ansiterm/tabwriter and updates table templates to support bold header wrapping. |
| cmd/sdk/find.go | Switches to ansiterm/tabwriter and bolds headers; fixes alignment with colored publisher badges. |
| cmd/internal/cmdutil/util_test.go | Updates tests to import the ansiterm/tabwriter package. |
Comment on lines
70
to
+72
| tool github.com/canonical/workshop/tools/try | ||
|
|
||
| replace github.com/juju/ansiterm => github.com/jonathan-conder/ansiterm v0.0.0-20260709033836-7b24c91012ac |
Comment on lines
803
to
805
| // Good: Use tabwriter for consistent table formatting | ||
| import "text/tabwriter" | ||
| import "github.com/juju/ansiterm/tabwriter" | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Fixes #925. Still in draft because I need to work out what to do about my ansiterm fork.
Self-review quick check
Docs
Procedure:
Content:
tutorial/andhow-to/sections).docs/.coverage.yamlupdated, coverage tags added (.. artefact).Or: