Skip to content

feat: allow multi-character corners on borders#695

Open
toller892 wants to merge 1 commit into
charmbracelet:mainfrom
toller892:feat/multi-char-corners
Open

feat: allow multi-character corners on borders#695
toller892 wants to merge 1 commit into
charmbracelet:mainfrom
toller892:feat/multi-char-corners

Conversation

@toller892

Copy link
Copy Markdown

Description

Remove the single-rune truncation on border corners (TopLeft, TopRight, BottomLeft, BottomRight).

Currently, applyBorder truncates all corner strings to a single rune (lines 406-410 in borders.go):

// For now, limit corners to one rune.
border.TopLeft = getFirstRuneAsString(border.TopLeft)
border.TopRight = getFirstRuneAsString(border.TopRight)
border.BottomRight = getFirstRuneAsString(border.BottomRight)
border.BottomLeft = getFirstRuneAsString(border.BottomLeft)

This prevents users from using multi-character corner decorations. However, the renderHorizontalEdge function already uses ansi.StringWidth to correctly handle multi-character left/right parts, so the truncation is unnecessary.

What changed

  • Removed the 4-line truncation block in applyBorder
  • Replaced with a comment explaining corners may be multi-character
  • Added tests verifying multi-character corners work correctly

Example

With this change, you can create borders like:

┌──                 ── ┐
│                      │
│                      │
└──                 ── ┘

Using a custom border:

customBorder := lipgloss.Border{
    Top:         "-",
    Bottom:      "-",
    Left:        "|",
    Right:       "|",
    TopLeft:     "──",
    TopRight:    "──",
    BottomLeft:  "──",
    BottomRight: "──",
}

Fixes #605

Remove the single-rune truncation on border corners (TopLeft, TopRight,
BottomLeft, BottomRight). The renderHorizontalEdge function already uses
ansi.StringWidth to correctly account for multi-character strings, so
the truncation was unnecessary.

This enables use cases like extended corner decorations:
  ┌──              ── ┐
  │                   │
  └──              ── ┘

Fixes charmbracelet#605
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.

Allow multi-character corners on borders

1 participant