fix(terminal): normalize imported padding for fitting

This commit is contained in:
Brennan Benson
2026-08-19 02:06:54 -07:00
parent a24f9bb510
commit 6df649163e
2 changed files with 5 additions and 6 deletions
+2 -2
View File
@@ -90,9 +90,9 @@ describe('mapGhosttyToOrca — window-padding', () => {
expect(result.unsupportedKeys).toEqual([])
})
it('preserves odd-sum dual-value padding as a fractional average', () => {
it('rounds odd-sum dual-value padding to the integer used for fitting', () => {
const result = mapGhosttyToOrca({ 'window-padding-x': '1,2' })
expect(result.diff).toEqual({ terminalPaddingX: 1.5 })
expect(result.diff).toEqual({ terminalPaddingX: 2 })
expect(result.unsupportedKeys).toEqual([])
})
+3 -4
View File
@@ -10,9 +10,8 @@ export const parseStrictInt = (v: string): number | null => {
return Number.isFinite(num) ? num : null
}
// Why: Ghostty accepts "top,bottom" / "left,right" pairs for window paddings,
// but Orca stores a single value per axis — average the pair so the total
// padding along the axis stays the same.
// Why: Orca stores one integer per axis, so collapse paired paddings to the
// nearest value that xterm's integer-based fit calculation will also use.
export const parsePaddingValue = (v: string): number | null => {
const parts = v.split(',')
if (parts.length > 2) {
@@ -26,5 +25,5 @@ export const parsePaddingValue = (v: string): number | null => {
}
nums.push(num)
}
return nums.reduce((sum, num) => sum + num, 0) / nums.length
return Math.round(nums.reduce((sum, num) => sum + num, 0) / nums.length)
}