fix(tui): preserve cursor position on Windows exit

This commit is contained in:
Kail Tian
2026-08-30 12:17:40 +08:00
committed by chengyongru
parent 2c87143f77
commit 1c1b13a3a9
3 changed files with 40 additions and 2 deletions
+25 -1
View File
@@ -1,6 +1,9 @@
import { describe, expect, test } from "bun:test"
import { createTuiHost } from "./host"
import {
configureOpenTuiEnvironment,
createTuiHost,
} from "./host"
async function settle(): Promise<void> {
await Bun.sleep(0)
@@ -8,6 +11,27 @@ async function settle(): Promise<void> {
}
describe("TUI host integration", () => {
test("disables the explicit-width probe on Windows", () => {
const environment: Record<string, string | undefined> = {}
configureOpenTuiEnvironment(environment, "win32")
expect(environment.OPENTUI_FORCE_EXPLICIT_WIDTH).toBe("false")
})
test("preserves explicit probe choices and leaves other platforms unchanged", () => {
const overridden = {
OPENTUI_FORCE_EXPLICIT_WIDTH: "true",
}
const nonWindows: Record<string, string | undefined> = {}
configureOpenTuiEnvironment(overridden, "win32")
configureOpenTuiEnvironment(nonWindows, "linux")
expect(overridden.OPENTUI_FORCE_EXPLICIT_WIDTH).toBe("true")
expect(nonWindows.OPENTUI_FORCE_EXPLICIT_WIDTH).toBeUndefined()
})
test("standalone terminals remain a no-op", async () => {
const commands: string[][] = []
const host = createTuiHost({}, async (command) => { commands.push([...command]) })