Skip to content

fix: border side getters now account for implicit borders#609

Open
veeceey wants to merge 1 commit intocharmbracelet:masterfrom
veeceey:fix/implicit-border-getters
Open

fix: border side getters now account for implicit borders#609
veeceey wants to merge 1 commit intocharmbracelet:masterfrom
veeceey:fix/implicit-border-getters

Conversation

@veeceey
Copy link
Copy Markdown

@veeceey veeceey commented Feb 10, 2026

Summary

  • Fixes the inconsistency where GetBorderTop(), GetBorderRight(), GetBorderBottom(), GetBorderLeft(), and GetBorder() returned false when a border style was set via BorderStyle() without explicitly enabling sides, even though the renderer treats all sides as enabled in this case.
  • The boolean getters now fall through to implicitBorders() — the same mechanism already used by the size getters (GetBorderTopSize, etc.) and the renderer (applyBorder) — making all three consistent.
  • Adds comprehensive tests covering implicit borders, explicit sides, no borders, frame size consistency, and the interaction between BorderStyle() and explicit side setters.

Fixes #522

Reproduction (before fix)

s := lipgloss.NewStyle().BorderStyle(lipgloss.NormalBorder())
fmt.Println(s.GetBorderLeft())            // false (wrong — border WILL render)
fmt.Println(s.GetHorizontalBorderSize())  // 2     (correct)
fmt.Println(s.GetHorizontalFrameSize())   // 2     (correct)

After this fix, GetBorderLeft() correctly returns true.

Test plan

  • All existing tests pass (including updated TestStyleUnset which was testing for the inconsistent behavior)
  • New TestGetBorderSidesWithImplicitBorders covers five scenarios:
    • BorderStyle() only (implicit borders) — all getters return true
    • Border() with explicit sides — only enabled sides return true
    • No border set — all getters return false
    • Frame size consistency with BorderStyle() + padding
    • BorderStyle() then explicit side setter disables implicit for other sides
  • go test ./... passes all packages (lipgloss, list, table, tree)

When a border style is set via BorderStyle() without explicitly
enabling/disabling individual sides, the renderer treats all sides as
enabled. However, the boolean getters (GetBorderTop, GetBorderRight,
GetBorderBottom, GetBorderLeft, GetBorder) incorrectly returned false,
creating an inconsistency between what is rendered and what the getters
report.

This also caused GetHorizontalFrameSize/GetVerticalFrameSize to return
values that didn't match the border side getters (the size methods
already handled implicit borders correctly via implicitBorders()).

The fix makes the boolean border getters fall through to
implicitBorders() — the same mechanism already used by the size getters
and the renderer — so all three are now consistent.

Fixes charmbracelet#522

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@veeceey
Copy link
Copy Markdown
Author

veeceey commented Feb 19, 2026

Friendly ping - any chance someone could take a look at this when they get a chance? Happy to make any changes if needed.

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.

BorderStyle without sides specified breaks size getters

1 participant