Fix DynamicBorder crash when theme not initialized

Make DynamicBorder defensive against undefined theme by checking
at render time instead of relying on default parameter closure.
This commit is contained in:
Mario Zechner 2026-01-02 01:15:45 +01:00
parent d51770a63d
commit 3ad5a168e7

View file

@ -7,8 +7,10 @@ import { theme } from "../theme/theme.js";
export class DynamicBorder implements Component {
private color: (str: string) => string;
constructor(color: (str: string) => string = (str) => theme.fg("border", str)) {
this.color = color;
constructor(color?: (str: string) => string) {
// Use provided color function, or default to theme border color
// Theme may not be initialized at construction time, so we check at render time
this.color = color ?? ((str) => (theme ? theme.fg("border", str) : str));
}
invalidate(): void {