Skip to content

Fix/ansi unicode tables#930

Draft
jonathan-conder wants to merge 2 commits into
mainfrom
fix/ansi-unicode-tables
Draft

Fix/ansi unicode tables#930
jonathan-conder wants to merge 2 commits into
mainfrom
fix/ansi-unicode-tables

Conversation

@jonathan-conder

Copy link
Copy Markdown
Contributor

Description

Fixes #925. Still in draft because I need to work out what to do about my ansiterm fork.

Self-review quick check

  • Make decisions that cost a lot to reverse explicit in the PR description.
  • Avoid nested conditions.
  • Delete dead code and redundant comments.
  • Normalise symmetries by sticking to doing identical things identically.
// one way to handle errors
if err := f(); err != nil {
   ...
}

// one way to handle multiple returns
val, err := f()
if err != nil {
   ...
}
...
  • Check that coupled code elements, files, and directories are adjacent. For example, test data is stored as close as possible to a test.
  • Put variable declaration and initialisation together.
  • Divide large expressions into digestable and self-explanatory ones. Use multiple variables if required.
  • Put a blank line between two logically different chunks of code.
  • Follow the style guide for new error messages.

Docs

Procedure:

  • I have checked and added or updated relevant documentation.
  • I have checked and added or updated relevant release notes.
  • I have included the technical author in the review.

Content:

  • Headings and titles accurately describe the content.
  • New and updated pages include correct metadata.
  • Documentation tests are added or updated where applicable (for tutorial/ and how-to/ sections).
  • Documentation follows the style guide.
  • If needed, docs/.coverage.yaml updated, coverage tags added (.. artefact).

Or:

  • I confirm the PR has no implications for documentation.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/tabwriter with github.com/juju/ansiterm/tabwriter (using StripEscape) 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.mod replace to a forked ansiterm version (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 thread go.mod
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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sdk find output missaligned

2 participants