Merge branch 'main' into feature/windows
This commit is contained in:
commit
c4f8bc1e90
2 files changed
+39
-1
No files matched your search
+12
-1
@@ -88,6 +88,8 @@ export function TerminalPane(props: {
|
|||||||
<embeddedTerminal
|
<embeddedTerminal
|
||||||
ref={terminal}
|
ref={terminal}
|
||||||
flexGrow={1}
|
flexGrow={1}
|
||||||
|
// Without a height of its own it starts at 24 rows, which can't shrink: a shorter box would clip it, and the program would draw rows nobody sees.
|
||||||
|
flexShrink={1}
|
||||||
minHeight={0}
|
minHeight={0}
|
||||||
width="100%"
|
width="100%"
|
||||||
onTerminalResize={function (this: EmbeddedTerminalRenderable, cols: number, rows: number) {
|
onTerminalResize={function (this: EmbeddedTerminalRenderable, cols: number, rows: number) {
|
||||||
@@ -162,6 +164,15 @@ function attachServer(session: T3Session, target: TerminalTarget, term: Embedded
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The emulator's answers, except that it doesn't know in-band resize (mode 2048). It says it
|
||||||
|
* does, but never sends the reports, and a program that takes it at its word, like Neovim,
|
||||||
|
* stops listening for SIGWINCH and so never sees the pane change size.
|
||||||
|
*/
|
||||||
|
function withoutInBandResize(data: Uint8Array): Uint8Array {
|
||||||
|
return Buffer.from(Buffer.from(data).toString("latin1").replace(/\x1b\[\?2048;\d\$y/g, "\x1b[?2048;0$y"), "latin1");
|
||||||
|
}
|
||||||
|
|
||||||
/** A program run here on its own pty, answering its terminal queries through the emulator. */
|
/** A program run here on its own pty, answering its terminal queries through the emulator. */
|
||||||
function spawnLocal(program: Extract<PaneProgram, { kind: "local" }>, term: EmbeddedTerminalRenderable, cols: number, rows: number, close: (message?: string) => void): Link {
|
function spawnLocal(program: Extract<PaneProgram, { kind: "local" }>, term: EmbeddedTerminalRenderable, cols: number, rows: number, close: (message?: string) => void): Link {
|
||||||
let stopped = false;
|
let stopped = false;
|
||||||
@@ -186,7 +197,7 @@ function spawnLocal(program: Extract<PaneProgram, { kind: "local" }>, term: Embe
|
|||||||
close();
|
close();
|
||||||
});
|
});
|
||||||
return {
|
return {
|
||||||
send: (data) => void child.terminal?.write(data),
|
send: (data, source) => void child.terminal?.write(source === "response" ? withoutInBandResize(data) : data),
|
||||||
resize: (next, height) => child.terminal?.resize(next, height),
|
resize: (next, height) => child.terminal?.resize(next, height),
|
||||||
stop: () => {
|
stop: () => {
|
||||||
if (stopped) return;
|
if (stopped) return;
|
||||||
|
|||||||
@@ -354,6 +354,33 @@ describe("terminal drawer", () => {
|
|||||||
expect(app.frame()).toContain("from the editor");
|
expect(app.frame()).toContain("from the editor");
|
||||||
expect(app.hints()).toStartWith("enter send");
|
expect(app.hints()).toStartWith("enter send");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("$EDITOR's terminal is the size of the box it's in, even a box shorter than 24 rows", async () => {
|
||||||
|
// It writes its size on its top and bottom rows, and again when that changes.
|
||||||
|
setEditor(`draw() { printf '\\033[2J\\033[1;1Htop %s\\033[999;1Hbottom %s' "$(stty size)" "$(stty size)"; }; trap draw WINCH; draw; for i in $(seq 50); do sleep 0.1; done #`);
|
||||||
|
const app = await open({ width: 100, height: 20 });
|
||||||
|
await app.press("i");
|
||||||
|
await app.press("g", { ctrl: true });
|
||||||
|
await waitFor(() => app.frame().includes("bottom "));
|
||||||
|
const rows = app.find("bottom ").y - app.find("top ").y + 1;
|
||||||
|
expect(app.frame()).toContain(`bottom ${rows} `);
|
||||||
|
// Zoomed, it gets the taller box.
|
||||||
|
await prefix(app, "z");
|
||||||
|
await waitFor(() => !app.frame().includes(`bottom ${rows} `));
|
||||||
|
const zoomed = app.find("bottom ").y - app.find("top ").y + 1;
|
||||||
|
expect(zoomed).toBeGreaterThan(rows);
|
||||||
|
expect(app.frame()).toContain(`bottom ${zoomed} `);
|
||||||
|
});
|
||||||
|
|
||||||
|
test("$EDITOR is told in-band resize isn't available, since no reports would come and it would miss the pane's size changing", async () => {
|
||||||
|
// It asks about mode 2048, as Neovim does, and shows the answer without its escape.
|
||||||
|
setEditor(`stty raw -echo; printf '\\033[?2048$p'; head -c 11 | tr -d '\\033'; sleep 5 #`);
|
||||||
|
const app = await open();
|
||||||
|
await app.press("i");
|
||||||
|
await app.press("g", { ctrl: true });
|
||||||
|
await waitFor(() => app.frame().includes("?2048;"));
|
||||||
|
expect(app.frame()).toContain("[?2048;0$y");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("the panes together", () => {
|
describe("the panes together", () => {
|
||||||
|
|||||||
Reference in new issue
Block a user