rich icon indicating copy to clipboard operation
rich copied to clipboard

Fix right justification: conditionally preserve trailing space character

Open BenRachmiel opened this issue 9 months ago • 0 comments

Type of changes

  • [x] Bug fix
  • [ ] New feature
  • [ ] Documentation / docstrings
  • [ ] Tests
  • [ ] Other

Checklist

  • [x] I've run the latest black with default args on new code.
  • [x] I've updated CHANGELOG.md and CONTRIBUTORS.md where appropriate.
  • [ ] I've added tests for new code.
  • [x] I accept that @willmcgugan may be pedantic in the code review.

Description

Please describe your changes here. If this fixes a bug, please link to the issue, if possible. #3641 details an issue with right justified titles of panels losing the trailing whitespace, and it being reassigned to the beginning of the segment. It appears that trailing whitespace is removed via rstrip, but titles have a singular space added after the text (I assume for visual clarity), which is inadvertently removed.

Seeing as this change might have knock-on effects, I attempted to mitigate that by using a ternary if, checking that the final character is a space and if so, leaving that space out of the rstrip. I have not added a test, since I do not know if the test mentioned in the issue is appropriate (seems very hardcoded), but could think up a regression test if necessary (don't know exactly how atm, but I could learn).

First time contributing to open source, hope this isn't a dumb way to tackle the issue, but I do see how it could have some unintended consequences.

BenRachmiel avatar Mar 02 '25 21:03 BenRachmiel