diff: Preserve hunk focus while scrolling
665d9d285e5a583311a99d7c8b66d8fe8eaf250f
Scrolling the diff should update the viewport without changing the active hunk. Keep hunk focus intact so brain review controls continue to target the selected hunk after a scroll. Assisted-by: Codex:gpt-5.5
1 parent
218534ed
crates/diff/src/viewer.rs
+3 -1
| 780 | 780 | .scroll |
|
| 781 | 781 | .scroll(scroll, self.scroll_rows(diff.rows), diff.rows); |
|
| 782 | 782 | if self.state.scroll.offset != previous |
|
| 783 | 783 | && let Some(file) = self.visible_file() |
|
| 784 | 784 | { |
|
| 785 | - | self.state.focus = Some(DiffFocus::File(file)); |
|
| 785 | + | if !matches!(self.state.focus, Some(DiffFocus::Hunk(_))) { |
|
| 786 | + | self.state.focus = Some(DiffFocus::File(file)); |
|
| 787 | + | } |
|
| 786 | 788 | if layout.tree.is_some() { |
|
| 787 | 789 | self.file_tree.select_file(file); |
|
| 788 | 790 | } |
|
| 789 | 791 | } |
|
| 790 | 792 | } |
a.rs
+0 -0
a.rs
+0 -0
b.rs
+0 -0
a.rs
+0 -0
a.rs
+0 -0
a.rs
+0 -0
b.rs
+0 -0
crates/diff/tests/golden/sticky_header_before_next_file_64x5.txt
+0 -0
src/a.rs
+0 -0
src/b.rs
+0 -0
README.md
+0 -0
src/app/a.rs
+0 -0
src/lib/b.rs
+0 -0
README.md
+0 -0
a.rs
+0 -0
b.rs
+0 -0
assets/css/style.css
+0 -0
assets/css/style.css
+0 -0
first.rs
+0 -0
second.rs
+0 -0
a.rs
+0 -0
a.rs
+0 -0
a.rs
+0 -0
a.rs
+0 -0
b.rs
+0 -0