diff options
| -rw-r--r-- | src/pardes.zig | 9 | ||||
| -rw-r--r-- | test/snapshots/ttyfollow.golden | 93 | ||||
| -rw-r--r-- | test/snapshots/ttyfollow.snap | 47 |
3 files changed, 146 insertions, 3 deletions
diff --git a/src/pardes.zig b/src/pardes.zig index 8fb0b43d..f647ed00 100644 --- a/src/pardes.zig +++ b/src/pardes.zig @@ -939,9 +939,12 @@ pub const Pardes = struct { const pane = p.panes[o.pane] orelse return; pane.tty_stream.appendSlice(p.gpa, o.bytes) catch {}; pane.stream.nextSlice(o.bytes); - // follow new output to the bottom — except in the pane being - // actively navigated in a text mode. - if (!(o.pane == p.active and pane.mode != .tty)) + // follow new output to the bottom only in tty mode; in + // normal/insert the user is reading scrollback and the view + // holds still while output streams in. Tag edits hijack + // pane.mode to insert — the body mode sits in tag_mode. + const bmode = if (pane.tag_edit) pane.tag_mode else pane.mode; + if (bmode == .tty) pane.vt.screens.active.scroll(.active); }, .eof => |e| p.removePane(e.pane), diff --git a/test/snapshots/ttyfollow.golden b/test/snapshots/ttyfollow.golden new file mode 100644 index 00000000..6142159f --- /dev/null +++ b/test/snapshots/ttyfollow.golden @@ -0,0 +1,93 @@ +== snap held-pre grid=100x30 cursor=4,15 +|Kill Newcol Tutor Debug Colors NextColor Dump +| NOR /tmp/pardes-snap/ttyfollow/cwd Del NOR /tmp/pardes-snap/ttyfollow/cwd Del +| 185 +| 186 s.txt +| 187 +| 188 +| 189 +| 190 +| 191 +| 192 +| 193 +| 194 +| 195 +| 196 +| 197 +| 198 +| NOR /tmp/pardes-snap/ttyfollow/cwd Del +| +| s.txt +| +| +| +| +| +| +| +| +| +| +| +== snap held-post grid=100x30 cursor=54,7 +|Kill Newcol Tutor Debug Colors NextColor Dump +| NOR /tmp/pardes-snap/ttyfollow/cwd Del TTY /tmp/pardes-snap/ttyfollow/cwd Del +| 185 $ ls +| 186 s.txt +| 187 $ touch go; until test -f done1; do sleep 0.05; +| 188 done; echo SYN''CED +| 189 SYNCED +| 190 $ +| 191 +| 192 +| 193 +| 194 +| 195 +| 196 +| 197 +| 198 +| NOR /tmp/pardes-snap/ttyfollow/cwd Del +| +| s.txt +| +| +| +| +| +| +| +| +| +| +| +== snap tty-follows grid=100x30 cursor=4,15 +|Kill Newcol Tutor Debug Colors NextColor Dump +| TTY /tmp/pardes-snap/ttyfollow/cwd Del TTY /tmp/pardes-snap/ttyfollow/cwd Del +| 288 $ ls +| 289 s.txt +| 290 $ touch go; until test -f done1; do sleep 0.05; +| 291 done; echo SYN''CED +| 292 SYNCED +| 293 $ +| 294 +| 295 +| 296 +| 297 +| 298 +| 299 +| 300 +| $ +| NOR /tmp/pardes-snap/ttyfollow/cwd Del +| +| s.txt +| +| +| +| +| +| +| +| +| +| +| diff --git a/test/snapshots/ttyfollow.snap b/test/snapshots/ttyfollow.snap new file mode 100644 index 00000000..e7303b4b --- /dev/null +++ b/test/snapshots/ttyfollow.snap @@ -0,0 +1,47 @@ +# follow-output gate: a shell pane in normal/insert mode holds its scrolled-up +# view while new pty output streams in (before: only the ACTIVE pane held); +# back in tty mode output follows to the bottom again. Pane A parks a +# background job blocked on file `go`, pane B triggers it and syncs on `done1`. +file s.txt x +start 30 100 -n 3 +wait 8000 s.txt +stable 700 20000 +key c-b +stable 600 8000 +text (until test -f go; do sleep 0.05; done; seq 201 260; touch done1) & +key enter +stable 500 8000 +text seq 1 200 +key enter +wait 8000 199 +stable 700 15000 +key c-b +stable 600 8000 +wheel up 10 8 +wheel up 10 8 +wheel up 10 8 +stable 500 8000 +snap held-pre +# focus pane B (right column), trigger A's job, sync on completion: A is now a +# NON-active normal-mode pane receiving output — its view must not move +press left 60 5 +release left 60 5 +stable 400 5000 +key c-b +stable 600 8000 +text touch go; until test -f done1; do sleep 0.05; done; echo SYN''CED +key enter +wait 8000 SYNCED +stable 700 15000 +snap held-post +# back in A, re-enter tty: the echoed keystrokes pull the view to the bottom +press left 10 8 +release left 10 8 +stable 400 5000 +key c-b +stable 600 8000 +text seq 261 300 +key enter +wait 8000 300 +stable 700 15000 +snap tty-follows |
