Skip to content

fix: Border.GetTopSize/GetBottomSize return row count, not rune width#672

Open
kimjune01 wants to merge 21 commits into
charmbracelet:masterfrom
kimjune01:fix/border-top-bottom-size
Open

fix: Border.GetTopSize/GetBottomSize return row count, not rune width#672
kimjune01 wants to merge 21 commits into
charmbracelet:masterfrom
kimjune01:fix/border-top-bottom-size

Conversation

@kimjune01
Copy link
Copy Markdown

Summary

  • Top and bottom borders always occupy exactly one row regardless of the display width of their rune characters
  • Previous implementation returned maxRuneWidth of border parts, which incorrectly reported >1 for wide-rune characters (e.g. emoji corners)
  • This caused GetVerticalBorderSize to overcount, breaking height calculations in Style.Render

Test plan

  • TestBorderGetTopBottomSize (normal, empty, wide-rune, partial borders)
  • CI passes

Fixes #112

dependabot Bot and others added 20 commits February 24, 2026 11:49
…armbracelet#618)

Bumps the all group with 2 updates in the / directory: [github.com/aymanbagabas/go-udiff](https://github.com/aymanbagabas/go-udiff) and [github.com/clipperhouse/displaywidth](https://github.com/clipperhouse/displaywidth).


Updates `github.com/aymanbagabas/go-udiff` from 0.3.1 to 0.4.0
- [Release notes](https://github.com/aymanbagabas/go-udiff/releases)
- [Commits](aymanbagabas/go-udiff@v0.3.1...v0.4.0)

Updates `github.com/clipperhouse/displaywidth` from 0.9.0 to 0.11.0
- [Release notes](https://github.com/clipperhouse/displaywidth/releases)
- [Changelog](https://github.com/clipperhouse/displaywidth/blob/main/CHANGELOG.md)
- [Commits](clipperhouse/displaywidth@v0.9.0...v0.11.0)

---
updated-dependencies:
- dependency-name: github.com/aymanbagabas/go-udiff
  dependency-version: 0.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all
- dependency-name: github.com/clipperhouse/displaywidth
  dependency-version: 0.11.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
fix: handle partial reads in queryTerminal
Co-authored-by: aymanbagabas <3187948+aymanbagabas@users.noreply.github.com>
Bumps the all group with 2 updates: [github.com/aymanbagabas/go-udiff](https://github.com/aymanbagabas/go-udiff) and [golang.org/x/sys](https://github.com/golang/sys).


Updates `github.com/aymanbagabas/go-udiff` from 0.4.0 to 0.4.1
- [Release notes](https://github.com/aymanbagabas/go-udiff/releases)
- [Commits](aymanbagabas/go-udiff@v0.4.0...v0.4.1)

Updates `golang.org/x/sys` from 0.41.0 to 0.42.0
- [Commits](golang/sys@v0.41.0...v0.42.0)

---
updated-dependencies:
- dependency-name: github.com/aymanbagabas/go-udiff
  dependency-version: 0.4.1
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all
- dependency-name: golang.org/x/sys
  dependency-version: 0.42.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
)

The current algorithm which calculates the first and last visible rows
does not take into account content wrapping (and has a number of other
problematic edge cases).

This is partially due to `expandRowHeights` actually not updating
`rowHeights`, but also due to a simplified implementation which does not
try to take them into account.

Rewrite the visible rows calculation to take content wrapping into
account, making sure we consider the actual row height that will be
used when rendering the table.
Co-authored-by: rohan436 <rohan.santhoshkumar@googlemail.com>
…oup (charmbracelet#630)

Bumps the all group with 1 update: [github.com/charmbracelet/colorprofile](https://github.com/charmbracelet/colorprofile).


Updates `github.com/charmbracelet/colorprofile` from 0.4.2 to 0.4.3
- [Release notes](https://github.com/charmbracelet/colorprofile/releases)
- [Commits](charmbracelet/colorprofile@v0.4.2...v0.4.3)

---
updated-dependencies:
- dependency-name: github.com/charmbracelet/colorprofile
  dependency-version: 0.4.3
  dependency-type: direct:production
  update-type: version-update:semver-patch
  dependency-group: all
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: rohan436 <rohan.santhoshkumar@googlemail.com>
…charmbracelet#640)

Bumps the all group with 1 update: [github.com/lucasb-eyer/go-colorful](https://github.com/lucasb-eyer/go-colorful).


Updates `github.com/lucasb-eyer/go-colorful` from 1.3.0 to 1.4.0
- [Release notes](https://github.com/lucasb-eyer/go-colorful/releases)
- [Changelog](https://github.com/lucasb-eyer/go-colorful/blob/master/CHANGELOG.md)
- [Commits](lucasb-eyer/go-colorful@v1.3.0...v1.4.0)

---
updated-dependencies:
- dependency-name: github.com/lucasb-eyer/go-colorful
  dependency-version: 1.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps the all group with 1 update: [golang.org/x/sys](https://github.com/golang/sys).


Updates `golang.org/x/sys` from 0.42.0 to 0.43.0
- [Commits](golang/sys@v0.42.0...v0.43.0)

---
updated-dependencies:
- dependency-name: golang.org/x/sys
  dependency-version: 0.43.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: all
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Which seems to happen if stdin/stdout are somehow accidentally not TTYs.

Signed-off-by: Justin Chadwell <justin@unikraft.com>
* docs: restore missing diaereses

See: charmbracelet#156

* chore(lint): remove deprecated directive
Top and bottom borders always occupy exactly one row regardless of the
display width of their rune characters. The previous implementation
returned maxRuneWidth of the border parts, which incorrectly reported
values >1 when wide-rune characters (e.g. "⏩") were used as corners.

This caused GetVerticalBorderSize to overcount, leading to wrong height
calculations in Style.Render when borders included wide-rune characters.

Fixes charmbracelet#112
@kimjune01 kimjune01 requested a review from meowgorithm as a code owner May 9, 2026 22:09
The bug (issue charmbracelet#112): GetTopSize/GetBottomSize returned rune width
instead of row count. Top/bottom borders always occupy exactly 1 row.

Test verification:
- main branch: FAIL (returns 2 for wide rune ⏩)
- fix branch: PASS (returns 1 correctly)

Attestation: main:FAIL fix:PASS TestBorderTopBottomSizeWithWideRune 2026-05-09T16:38:46
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.

8 participants