diff --git a/crates/dv_ui/src/diff_pane/tests/threads.rs b/crates/dv_ui/src/diff_pane/tests/threads.rs index ecf6fd0..5a86ecf 100644 --- a/crates/dv_ui/src/diff_pane/tests/threads.rs +++ b/crates/dv_ui/src/diff_pane/tests/threads.rs @@ -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"))); +} diff --git a/crates/dv_ui/src/diff_pane/threads.rs b/crates/dv_ui/src/diff_pane/threads.rs index 1d2c1be..651a78d 100644 --- a/crates/dv_ui/src/diff_pane/threads.rs +++ b/crates/dv_ui/src/diff_pane/threads.rs @@ -802,7 +802,7 @@ impl DiffPane { cx.notify(); } - fn posted( + pub(super) fn posted( &mut self, target: ComposerTarget, result: Result, @@ -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); }