summaryrefslogtreecommitdiff
path: root/core/echo.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/echo.zig')
-rw-r--r--core/echo.zig13
1 files changed, 7 insertions, 6 deletions
diff --git a/core/echo.zig b/core/echo.zig
index 93b877b8..b1200ca2 100644
--- a/core/echo.zig
+++ b/core/echo.zig
@@ -237,7 +237,7 @@ pub const Echo = struct {
fn predict(e: *Echo, pane: *Pane, kind: Kind, seq: u32) bool {
const state = pane.terminal orelse return false;
const g = Term.grid(state);
- if (Term.modes(state).alternate or g.offset + g.len < g.total or !g.cursor_visible) return false;
+ if (Term.modes(state).alternate or pane.termTop() + g.len < g.total or !g.cursor_visible) return false;
const top = e.tops[e.pane];
const cur: Cursor = e.cursor orelse .{ .x = g.cursor_x, .row = top + g.cursor_y, .seq = 0 };
if (cur.row < top or cur.row - top >= g.len or e.n == max) return false;
@@ -457,17 +457,18 @@ pub const Echo = struct {
const top = e.tops[id];
// Off a prompt, the trust is inferred: underlined, as mosh does.
const flag = !atPrompt(pane);
+ const shown = pane.termTop();
const at = struct {
- fn f(sb_: @TypeOf(sb), pan: u16, h: u16, top_: u64, row: u64) ?u16 {
+ fn f(sb_: @TypeOf(sb), shown_: usize, pan: u16, h: u16, top_: u64, row: u64) ?u16 {
if (row < top_ or row - top_ >= sb_.len) return null;
const screen_row = sb_.total - sb_.len + (row - top_);
- if (screen_row < sb_.offset + pan) return null;
- const y = screen_row - sb_.offset - pan;
+ if (screen_row < shown_ + pan) return null;
+ const y = screen_row - shown_ - pan;
return if (y < h) @intCast(y) else null;
}
}.f;
for (e.cells[0..e.n]) |cell| {
- const y = at(sb, pane.pan, body_h, top, cell.row) orelse continue;
+ const y = at(sb, shown, pane.pan, body_h, top, cell.row) orelse continue;
if (cell.x >= tw) continue;
const dst = s.at(tx + cell.x, body_y + y);
// Typed text continues the text before it (mosh's heuristic).
@@ -484,7 +485,7 @@ pub const Echo = struct {
}
if (!active or pane.focus != .body) return;
const cur = e.cursor orelse return;
- const y = at(sb, pane.pan, body_h, top, cur.row) orelse return;
+ const y = at(sb, shown, pane.pan, body_h, top, cur.row) orelse return;
if (cur.x < tw) s.cursor = .{ .x = tx + cur.x, .y = body_y + y };
}
};