Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions crates/dv_ui/src/diff_pane/tests/threads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -704,3 +704,32 @@ fn a_reply_opened_near_the_bottom_comes_wholly_into_view(cx: &mut TestAppContext
"the card ends at {bottom}, past the viewport's {height}"
);
}

/// A post's answer can reach the pane after the review's reload has already drawn the new
/// card (a loaded machine): the card is revealed then, and nothing is left waiting to scroll
/// the stream back to it on a later change.
#[gpui::test]
fn a_post_answered_after_its_card_is_drawn_leaves_nothing_to_reveal_later(cx: &mut TestAppContext) {
let repo = stream_fixture(80);
let (_dir, shell, cx) = open(&repo, cx);
let pane = pane(&shell, cx);
let thread = add_thread(&shell, "b.txt", AnchorSide::New, (2, 2), "Why a digit?", cx);
let target = ComposerTarget {
path: "b.txt".to_string(),
side: AnchorSide::New,
start_line: 2,
end_line: 2,
reply_to: None,
};
pane.update_in(cx, |pane, window, cx| {
pane.posted(target, Ok(thread.clone()), window, cx);
});
settle_drawn(cx, &shell, "the answer", |_, _| true);
assert_eq!(focused(&pane, cx), Some(thread));

// The reader moves on to c.txt; a later change to the rows (`S`) leaves them there.
press(cx, &shell, "j j");
pane.read_with(cx, |pane, _| assert_eq!(pane.top_file(), Some("c.txt")));
press(cx, &shell, "s");
pane.read_with(cx, |pane, _| assert_eq!(pane.top_file(), Some("c.txt")));
}
7 changes: 6 additions & 1 deletion crates/dv_ui/src/diff_pane/threads.rs
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ impl DiffPane {
cx.notify();
}

fn posted(
pub(super) fn posted(
&mut self,
target: ComposerTarget,
result: Result<ThreadId, Failure>,
Expand All @@ -824,6 +824,11 @@ impl DiffPane {
}
self.focused_thread = Some(thread.clone());
self.pending_thread = Some(thread);
// The review's reload can draw the card before this answer comes (a loaded
// machine), leaving no change to its rows to reveal it on: it is revealed now
// if it is there, else once it is drawn.
self.reveal_pending_thread();
self.viewport_changed(cx);
if let Some(path) = self.target_block_path(&target, cx) {
self.refresh_path(&path, cx);
}
Expand Down
Loading