fix(tui): normalize undefined to null for optional napi parameters on Windows
Bun's JSC napi layer on Windows does not reliably report undefined as napi_undefined, causing napi-rs Option<bool> to fall through to bool::from_napi_value() and throw: Error: Failed to convert napi value into rust type bool Pass null instead of undefined for ellipsisKind, pad (truncateToWidth) and strict (sliceWithWidth) via ?? null. null maps to napi_null which napi-rs detects correctly on all platforms.
This commit is contained in:
@@ -12,7 +12,7 @@ export { Ellipsis } from "@oh-my-pi/pi-natives";
|
||||
export { getDefaultTabWidth, getIndentation } from "@oh-my-pi/pi-utils";
|
||||
|
||||
export function sliceWithWidth(line: string, startCol: number, length: number, strict?: boolean | null): SliceResult {
|
||||
return nativeSliceWithWidth(line, startCol, length, strict, getDefaultTabWidth());
|
||||
return nativeSliceWithWidth(line, startCol, length, strict ?? null, getDefaultTabWidth());
|
||||
}
|
||||
|
||||
export function truncateToWidth(
|
||||
@@ -21,7 +21,7 @@ export function truncateToWidth(
|
||||
ellipsisKind?: Ellipsis | null,
|
||||
pad?: boolean | null,
|
||||
): string {
|
||||
return nativeTruncateToWidth(text, maxWidth, ellipsisKind, pad, getDefaultTabWidth());
|
||||
return nativeTruncateToWidth(text, maxWidth, ellipsisKind ?? null, pad ?? null, getDefaultTabWidth());
|
||||
}
|
||||
|
||||
export function wrapTextWithAnsi(text: string, width: number): string[] {
|
||||
|
||||
Reference in New Issue
Block a user