fix(server): advertise 256-color TERM on Windows terminals (#5693)
This commit is contained in:
1 parent
1fa315ea93
commit
c14bcca103
2 files changed
+39
-4
No files matched your search
@@ -33,6 +33,7 @@ const testLayer = NodePtyAdapter.layer.pipe(
|
||||
|
||||
it.effect("spawns through the public adapter with the provided host references", () =>
|
||||
Effect.gen(function* () {
|
||||
spawn.mockClear();
|
||||
const adapter = yield* PtyAdapter.PtyAdapter;
|
||||
const process = yield* adapter.spawn({
|
||||
shell: "powershell.exe",
|
||||
@@ -52,8 +53,35 @@ it.effect("spawns through the public adapter with the provided host references",
|
||||
cwd: "C:\\workspace",
|
||||
cols: 120,
|
||||
rows: 40,
|
||||
env: {},
|
||||
name: "xterm-color",
|
||||
env: { TERM: "xterm-256color" },
|
||||
name: "xterm-256color",
|
||||
},
|
||||
]);
|
||||
}).pipe(Effect.provide(testLayer)),
|
||||
);
|
||||
|
||||
it.effect("preserves a caller-provided TERM in the spawn env on win32", () =>
|
||||
Effect.gen(function* () {
|
||||
spawn.mockClear();
|
||||
const adapter = yield* PtyAdapter.PtyAdapter;
|
||||
yield* adapter.spawn({
|
||||
shell: "powershell.exe",
|
||||
cwd: "C:\\workspace",
|
||||
cols: 80,
|
||||
rows: 24,
|
||||
env: { TERM: "xterm-direct" },
|
||||
});
|
||||
|
||||
assert.equal(spawn.mock.calls.length, 1);
|
||||
assert.deepEqual(spawn.mock.calls[0], [
|
||||
"powershell.exe",
|
||||
[],
|
||||
{
|
||||
cwd: "C:\\workspace",
|
||||
cols: 80,
|
||||
rows: 24,
|
||||
env: { TERM: "xterm-direct" },
|
||||
name: "xterm-256color",
|
||||
},
|
||||
]);
|
||||
}).pipe(Effect.provide(testLayer)),
|
||||
|
||||
@@ -141,14 +141,21 @@ export const make = Effect.fn("NodePtyAdapter.make")(function* (
|
||||
return PtyAdapter.PtyAdapter.of({
|
||||
spawn: Effect.fn("NodePtyAdapter.spawn")(function* (input) {
|
||||
yield* ensureNodePtySpawnHelperExecutableCached;
|
||||
// node-pty only writes `name` into the child's TERM on the Unix path;
|
||||
// the ConPTY path leaves the environment untouched, so Windows children
|
||||
// inherit a missing or 16-color TERM unless it is set here.
|
||||
const env =
|
||||
platform === "win32" && input.env["TERM"] === undefined
|
||||
? { ...input.env, TERM: "xterm-256color" }
|
||||
: input.env;
|
||||
const ptyProcess = yield* Effect.try({
|
||||
try: () =>
|
||||
nodePty.spawn(input.shell, input.args ?? [], {
|
||||
cwd: input.cwd,
|
||||
cols: input.cols,
|
||||
rows: input.rows,
|
||||
env: input.env,
|
||||
name: platform === "win32" ? "xterm-color" : "xterm-256color",
|
||||
env,
|
||||
name: "xterm-256color",
|
||||
}),
|
||||
catch: (cause) =>
|
||||
new PtyAdapter.PtySpawnError({
|
||||
|
||||
Reference in new issue
Block a user