lipgloss icon indicating copy to clipboard operation
lipgloss copied to clipboard

Fix border width calculation in renderHorizontalEdge

Open akaoio opened this issue 4 months ago • 1 comments

Summary

  • Fixes an off-by-one error in renderHorizontalEdge that caused borders to render with incorrect width
  • Ensures right border width is properly accounted for in total width calculation
  • Corrects the loop logic to fill exactly the required middle section width

Problem

The renderHorizontalEdge function had a bug where:

  1. The right border width wasn't being properly subtracted when calculating the middle section
  2. The loop iteration logic could cause borders to overflow or underflow their intended width

This was particularly noticeable with wider borders or specific width values.

Solution

  • Calculate middle width as width - leftWidth - rightWidth
  • Fix the loop to iterate exactly over the middle width
  • Add width accounting for right borders in applyBorder
  • Add comprehensive tests to verify correct border rendering at various widths

Test Plan

✅ Added TestRenderHorizontalEdgeFix with multiple test cases ✅ All existing tests pass ✅ Verified borders render at exact specified widths

🤖 Generated with Claude Code

akaoio avatar Aug 23 '25 13:08 akaoio

Thanks for this. In order for us to verify the issue, can you put together some sample code to verify the issue exists? This will greatly help us expedite our ability to review the PR.

meowgorithm avatar Aug 31 '25 12:08 meowgorithm