Skip to content

Conversation

caarlos0
Copy link
Member

also, if the screen is too narrow, use ansi truncate to prevent breaking things.

caarlos0 added 2 commits June 18, 2025 13:14
Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>
@caarlos0 caarlos0 requested review from meowgorithm and Copilot June 18, 2025 16:19
@caarlos0 caarlos0 self-assigned this Jun 18, 2025
@caarlos0 caarlos0 added the bug Something isn't working label Jun 18, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

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 refactors how codeblock widths are calculated and truncates long example lines on narrow terminals.

  • Simplify width computation by unifying usage and example widths with padding.
  • Add ansi.Truncate to clamp examples that exceed available width.
  • Shorten example command’s Short description.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
help.go Unified width logic, import ansi, truncate long examples
example/main.go Updated Short description for the throw command
Comments suppressed due to low confidence (3)

help.go:58

  • New truncation logic is introduced here; consider adding unit tests to verify that long examples are correctly truncated when exceeding cw.
				examples[i] = ansi.Truncate(example, cw, "…")

help.go:61

  • The strings package is used here but not imported; add import "strings" to avoid a compile error.
		_, _ = fmt.Fprintln(w, styles.Codeblock.Base.Render(strings.Join(examples, "\n")))

help.go:68

  • The leftPadding variable is declared but never used; consider removing it to keep the code clean.
	leftPadding := 4

@caarlos0 caarlos0 merged commit 59a0711 into main Jun 18, 2025
12 of 18 checks passed
@caarlos0 caarlos0 deleted the width branch June 18, 2025 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant