Diff View: Scroll to center of hunks when reviewing (#25846)
When reviewing hunks, scroll to put them at the center of the screen so you can better see the context around that hunk. The field `center_cursor` was added to the actions `editor::GoToHunk` and `editor::GoToPrevHunk`, this was set to `false` by default in keymaps, as it wouldn't help with in-editor navigation. The field is set to `true` for when you trigger `git::StageAndNext` and `git::UnstageAndNext`, this is also `true` for the buttons in the Diff View toolbar. Release Notes: - N/A
This commit is contained in:
parent
a2876f5d3e
commit
2d61a51ded
13 changed files with 140 additions and 66 deletions
|
@ -869,12 +869,20 @@ impl Render for ProjectDiffToolbar {
|
|||
.shape(ui::IconButtonShape::Square)
|
||||
.tooltip(Tooltip::for_action_title_in(
|
||||
"Go to previous hunk",
|
||||
&GoToPrevHunk,
|
||||
&GoToPrevHunk {
|
||||
center_cursor: false,
|
||||
},
|
||||
&focus_handle,
|
||||
))
|
||||
.disabled(!button_states.prev_next)
|
||||
.on_click(cx.listener(|this, _, window, cx| {
|
||||
this.dispatch_action(&GoToPrevHunk, window, cx)
|
||||
this.dispatch_action(
|
||||
&GoToPrevHunk {
|
||||
center_cursor: true,
|
||||
},
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
})),
|
||||
)
|
||||
.child(
|
||||
|
@ -882,12 +890,20 @@ impl Render for ProjectDiffToolbar {
|
|||
.shape(ui::IconButtonShape::Square)
|
||||
.tooltip(Tooltip::for_action_title_in(
|
||||
"Go to next hunk",
|
||||
&GoToHunk,
|
||||
&GoToHunk {
|
||||
center_cursor: false,
|
||||
},
|
||||
&focus_handle,
|
||||
))
|
||||
.disabled(!button_states.prev_next)
|
||||
.on_click(cx.listener(|this, _, window, cx| {
|
||||
this.dispatch_action(&GoToHunk, window, cx)
|
||||
this.dispatch_action(
|
||||
&GoToHunk {
|
||||
center_cursor: true,
|
||||
},
|
||||
window,
|
||||
cx,
|
||||
)
|
||||
})),
|
||||
),
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue