Skip to content

Conversation

aymanbagabas
Copy link
Member

@aymanbagabas aymanbagabas commented Mar 12, 2025

Padding should use a non-breaking space so that the padding is preserved when the string is being copied and pasted, and wrapped to the next line.

Now, we use " " for margins, and "\u00a0" for paddings to preserve the surrounding spacing with the padded word.

@aymanbagabas aymanbagabas changed the title fix: use non-breaking space for padding (v2) fix: use non-breaking space for padding Mar 26, 2025
Copy link
Member

@meowgorithm meowgorithm left a comment

Choose a reason for hiding this comment

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

This is a solid one. Let's get it into the release today.

@andreynering
Copy link
Member

CI failing. Tests need to be updated.

Padding should use a non-breaking space so that the padding is preserved
when the string is being copied and pasted, and wrapped to the next line.
@aymanbagabas aymanbagabas merged commit 43ba573 into v2-exp Mar 26, 2025
13 checks passed
@aymanbagabas aymanbagabas deleted the v2-nbsp branch March 26, 2025 17:58
@aymanbagabas aymanbagabas requested a review from Copilot March 26, 2025 18:09
Copy link

@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 updates the code to use a non-breaking space (U+00A0) for padding, ensuring that the formatting is preserved during copy-paste and line wrapping.

  • Updated expected output strings in table/table_test.go to include non-breaking spaces for padded text.
  • Modified style.go to pass an explicit padding character (either a non-breaking space for padding or a regular space for margins) through updated padLeft, padRight, and pad functions.

Reviewed Changes

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

File Description
table/table_test.go Updated test expectations to reflect non-breaking space usage.
style.go Refactored padding functions to use a configurable padding rune.
Files not reviewed (18)
  • list/testdata/TestComplexSublist.golden: Language not supported
  • list/testdata/TestEnumerators/alphabet.golden: Language not supported
  • list/testdata/TestEnumerators/arabic.golden: Language not supported
  • list/testdata/TestEnumerators/asterisk.golden: Language not supported
  • list/testdata/TestEnumerators/bullet.golden: Language not supported
  • list/testdata/TestEnumerators/dash.golden: Language not supported
  • list/testdata/TestEnumerators/roman.golden: Language not supported
  • list/testdata/TestEnumeratorsAlign.golden: Language not supported
  • list/testdata/TestEnumeratorsTransform/alphabet_lower.golden: Language not supported
  • list/testdata/TestEnumeratorsTransform/arabic).golden: Language not supported
  • list/testdata/TestList.golden: Language not supported
  • list/testdata/TestListIntegers.golden: Language not supported
  • list/testdata/TestListItems.golden: Language not supported
  • list/testdata/TestMultiline.golden: Language not supported
  • list/testdata/TestSubListItems2.golden: Language not supported
  • list/testdata/TestSublist.golden: Language not supported
  • list/testdata/TestSublistItems.golden: Language not supported
  • table/testdata/TestBorderColumnsWithExtraRows.golden: Language not supported
Comments suppressed due to low confidence (2)

style.go:13

  • [nitpick] The constant 'nbsp' could be renamed to 'nonBreakingSpace' for improved clarity.
nbsp            = '\u00A0'

style.go:532

  • Ensure that all call sites of 'pad' are updated to pass the appropriate padding rune to avoid unintended padding behavior.
func pad(str string, n int, style *ansi.Style, r rune) string {

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.

5 participants