diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-29 08:14:42 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-10-01 00:12:16 -0300 |
| commit | a630f5e83ef9efabca790770112dcea689384631 (patch) | |
| tree | 390d6e6b08cba9e0964d05af1f8d0005aba47c6c /src/pardes.zig | |
| parent | 2f1b7cd5fb82e619043ccb34826154a53e53c28e (diff) | |
| download | pardes-a630f5e83ef9efabca790770112dcea689384631.tar.gz pardes-a630f5e83ef9efabca790770112dcea689384631.zip | |
A new terminal's greeting `ls` goes at its shell's first prompt or never
The greeting waited for any moment the cursor sat at a prompt's input, so
where the first prompt was missed (a resize still pending, a line written
before it), `ls` was typed later into whatever ran then. It is now sent
only while nothing has run (pardes's marks saw no command start) and
nothing is typed at the prompt; past that it is dropped, never typed late.
A prompt drawn again for a resize is still the first.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'src/pardes.zig')
| -rw-r--r-- | src/pardes.zig | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/pardes.zig b/src/pardes.zig index 3a574dc9..de4d6abc 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -6686,11 +6686,19 @@ pub const Pardes = struct { if (pane.file) |*file| file.syntax_dirty = true; } panes.Terminal.releasePendingCommandIfReady(p, id, pane); - if (pane.greet and pane.isTerminal() and p.resize_count > 0 and panes.Terminal.promptInputReady(pane)) { - p.emit(.{ .resize_pty = .{ .pane = @intCast(id), .cols = pane.cols, .rows = pane.rows } }); - p.emit(.{ .write = .{ .pane = @intCast(id), .bytes = .from("ls\r") } }); - pane.greet = false; - } + // The greeting `ls` of a new terminal in a directory is typed at + // its shell's FIRST prompt, or never: typed later it would land + // in whatever runs then, or in the middle of a line someone + // typed (panes.Terminal.greeting). + if (pane.greet and pane.isTerminal() and p.resize_count > 0) switch (panes.Terminal.greeting(pane)) { + .wait => {}, + .never => pane.greet = false, + .now => { + p.emit(.{ .resize_pty = .{ .pane = @intCast(id), .cols = pane.cols, .rows = pane.rows } }); + p.emit(.{ .write = .{ .pane = @intCast(id), .bytes = .from("ls\r") } }); + pane.greet = false; + }, + }; } } |
