mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-13 19:46:16 +03:00
fix(tui): roll the compact form over to M at the rounding boundary (#55871)
Co-authored-by: argszero <argszero@users.noreply.github.com> Co-authored-by: Tarquinen <78942835+Tarquinen@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
Unverified
parent
13263f30ed
commit
2e7ac8c8ea
@@ -17,7 +17,8 @@ export function datetime(input: number): string {
|
||||
}
|
||||
|
||||
export function number(num: number): string {
|
||||
if (num >= 1000000) {
|
||||
// 999950+ would round to "1000.0K"
|
||||
if (num >= 999950) {
|
||||
return (num / 1000000).toFixed(1) + "M"
|
||||
} else if (num >= 1000) {
|
||||
return (num / 1000).toFixed(1) + "K"
|
||||
|
||||
@@ -12,3 +12,9 @@ test("takes whole graphemes within terminal width", () => {
|
||||
expect(Locale.takeWidth("ab界cd", 4)).toBe("ab界")
|
||||
expect(Locale.graphemes("a👨👩👧👦b")).toEqual(["a", "👨👩👧👦", "b"])
|
||||
})
|
||||
|
||||
test("rolls the compact form over at the rounding boundary", () => {
|
||||
expect(Locale.number(999949)).toBe("999.9K")
|
||||
expect(Locale.number(999950)).toBe("1.0M")
|
||||
expect(Locale.number(1000000)).toBe("1.0M")
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user