mux: add bonus lines to GetTabRenderChangesResponse
The server now uses this to send the line content for whichever line the cursor is on, which makes typing latency better.
This commit is contained in:
1 parent
b384ee4233
commit
57ad948af1
3 files changed
+22
-7
No files matched your search
@@ -426,6 +426,9 @@ pub struct GetTabRenderChangesResponse {
|
||||
pub dimensions: RenderableDimensions,
|
||||
pub dirty_lines: Vec<Range<StableRowIndex>>,
|
||||
pub title: String,
|
||||
/// Lines that the server thought we'd almost certainly
|
||||
/// want to fetch as soon as we received this response
|
||||
pub bonus_lines: SerializedLines,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, PartialEq, Debug)]
|
||||
|
||||
@@ -408,6 +408,16 @@ fn maybe_push_tab_changes(
|
||||
|
||||
let title = tab.get_title();
|
||||
|
||||
let (cursor_line, lines) = tab
|
||||
.renderer()
|
||||
.get_lines(cursor_position.y..cursor_position.y + 1);
|
||||
let bonus_lines = lines
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
.map(|(idx, line)| (cursor_line + idx as StableRowIndex, line))
|
||||
.collect::<Vec<_>>()
|
||||
.into();
|
||||
|
||||
sender.send(DecodedPdu {
|
||||
pdu: Pdu::GetTabRenderChangesResponse(GetTabRenderChangesResponse {
|
||||
tab_id,
|
||||
@@ -416,6 +426,7 @@ fn maybe_push_tab_changes(
|
||||
dimensions: dims,
|
||||
cursor_position,
|
||||
title,
|
||||
bonus_lines,
|
||||
}),
|
||||
serial: 0,
|
||||
})?;
|
||||
|
||||
+8
-7
@@ -348,20 +348,21 @@ impl RenderableInner {
|
||||
|
||||
if delta.cursor_position != self.cursor_position {
|
||||
self.dirty_rows.add(self.cursor_position.y);
|
||||
// But note that the server may have sent this in bonus_lines;
|
||||
// we'll address that below
|
||||
self.dirty_rows.add(delta.cursor_position.y);
|
||||
log::trace!(
|
||||
"cursor move, so dirty {} and {}. to_fetch is {:?}",
|
||||
self.cursor_position.y,
|
||||
delta.cursor_position.y,
|
||||
to_fetch
|
||||
);
|
||||
|
||||
to_fetch.add(delta.cursor_position.y);
|
||||
}
|
||||
self.cursor_position = delta.cursor_position;
|
||||
self.dimensions = delta.dimensions;
|
||||
self.title = delta.title;
|
||||
|
||||
for (stable_row, line) in delta.bonus_lines.lines() {
|
||||
to_fetch.remove(stable_row);
|
||||
self.dirty_rows.add(stable_row);
|
||||
self.lines.put(stable_row, line);
|
||||
}
|
||||
|
||||
self.fetch_lines(to_fetch);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user