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:
João Marcos
2025-03-01 03:20:26 +00:00
committed by GitHub
parent a2876f5d3e
commit 2d61a51ded
13 changed files with 140 additions and 66 deletions
+4 -4
View File
@@ -372,8 +372,8 @@
"ctrl-alt-y": "git::ToggleStaged",
"alt-y": ["git::StageAndNext", { "whole_excerpt": false }],
"alt-shift-y": ["git::UnstageAndNext", { "whole_excerpt": false }],
"alt-.": "editor::GoToHunk",
"alt-,": "editor::GoToPrevHunk"
"alt-.": ["editor::GoToHunk", { "center_cursor": true }],
"alt-,": ["editor::GoToPrevHunk", { "center_cursor": true }]
}
},
{
@@ -564,8 +564,8 @@
"shift-enter": "editor::ExpandExcerpts",
"ctrl-alt-enter": "editor::OpenExcerptsSplit",
"ctrl-shift-e": "pane::RevealInProjectPanel",
"ctrl-f8": "editor::GoToHunk",
"ctrl-shift-f8": "editor::GoToPrevHunk",
"ctrl-f8": ["editor::GoToHunk", { "center_cursor": true }],
"ctrl-shift-f8": ["editor::GoToPrevHunk", { "center_cursor": true }],
"ctrl-enter": "assistant::InlineAssist",
"ctrl-:": "editor::ToggleInlayHints"
}
+2 -2
View File
@@ -640,8 +640,8 @@
"shift-enter": "editor::ExpandExcerpts",
"cmd-alt-enter": "editor::OpenExcerptsSplit",
"cmd-shift-e": "pane::RevealInProjectPanel",
"cmd-f8": "editor::GoToHunk",
"cmd-shift-f8": "editor::GoToPrevHunk",
"cmd-f8": ["editor::GoToHunk", { "center_cursor": true }],
"cmd-shift-f8": ["editor::GoToPrevHunk", { "center_cursor": true }],
"ctrl-enter": "assistant::InlineAssist",
"ctrl-:": "editor::ToggleInlayHints"
}
+2 -2
View File
@@ -42,8 +42,8 @@
"ctrl-alt-shift-b": "editor::GoToTypeDefinitionSplit",
"f2": "editor::GoToDiagnostic",
"shift-f2": "editor::GoToPrevDiagnostic",
"ctrl-alt-shift-down": "editor::GoToHunk",
"ctrl-alt-shift-up": "editor::GoToPrevHunk",
"ctrl-alt-shift-down": ["editor::GoToHunk", { "center_cursor": true }],
"ctrl-alt-shift-up": ["editor::GoToPrevHunk", { "center_cursor": true }],
"ctrl-alt-z": "git::Restore",
"ctrl-home": "editor::MoveToBeginning",
"ctrl-end": "editor::MoveToEnd",
+2 -2
View File
@@ -43,8 +43,8 @@
"ctrl-f12": "editor::GoToDefinitionSplit",
"shift-f12": "editor::FindAllReferences",
"ctrl-shift-f12": "editor::FindAllReferences",
"ctrl-.": "editor::GoToHunk",
"ctrl-,": "editor::GoToPrevHunk",
"ctrl-.": ["editor::GoToHunk", { "center_cursor": true }],
"ctrl-,": ["editor::GoToPrevHunk", { "center_cursor": true }],
"ctrl-k ctrl-u": "editor::ConvertToUpperCase",
"ctrl-k ctrl-l": "editor::ConvertToLowerCase",
"shift-alt-m": "markdown::OpenPreviewToTheSide",
+2 -2
View File
@@ -40,8 +40,8 @@
"cmd-alt-shift-b": "editor::GoToTypeDefinitionSplit",
"f2": "editor::GoToDiagnostic",
"shift-f2": "editor::GoToPrevDiagnostic",
"ctrl-alt-shift-down": "editor::GoToHunk",
"ctrl-alt-shift-up": "editor::GoToPrevHunk",
"ctrl-alt-shift-down": ["editor::GoToHunk", { "center_cursor": true }],
"ctrl-alt-shift-up": ["editor::GoToPrevHunk", { "center_cursor": true }],
"cmd-home": "editor::MoveToBeginning",
"cmd-end": "editor::MoveToEnd",
"cmd-shift-home": "editor::SelectToBeginning",
+2 -2
View File
@@ -44,8 +44,8 @@
"alt-cmd-down": "editor::GoToDefinition",
"ctrl-alt-cmd-down": "editor::GoToDefinitionSplit",
"alt-shift-cmd-down": "editor::FindAllReferences",
"ctrl-.": "editor::GoToHunk",
"ctrl-,": "editor::GoToPrevHunk",
"ctrl-.": ["editor::GoToHunk", { "center_cursor": true }],
"ctrl-,": ["editor::GoToPrevHunk", { "center_cursor": true }],
"cmd-k cmd-u": "editor::ConvertToUpperCase",
"cmd-k cmd-l": "editor::ConvertToLowerCase",
"cmd-shift-j": "editor::JoinLines",
+2 -2
View File
@@ -238,8 +238,8 @@
"] x": "vim::SelectSmallerSyntaxNode",
"] d": "editor::GoToDiagnostic",
"[ d": "editor::GoToPrevDiagnostic",
"] c": "editor::GoToHunk",
"[ c": "editor::GoToPrevHunk",
"] c": ["editor::GoToHunk", { "center_cursor": true }],
"[ c": ["editor::GoToPrevHunk", { "center_cursor": true }],
"g c": "vim::PushToggleComments"
}
},