git: New enter behaviour (#25986)
Closes #25951 Release Notes: - git: Update "enter" in the list of changed files to preserve focus. If you want the old behaviour, hit enter twice. - git: Follow the cursor, not the scroll anchor, in the list. Although the scroll anchor was nice for passive scrolling, it broke if you had changed the overflow scroll settings.
This commit is contained in:
@@ -709,12 +709,31 @@ impl GitPanel {
|
||||
fn open_diff(&mut self, _: &menu::Confirm, window: &mut Window, cx: &mut Context<Self>) {
|
||||
maybe!({
|
||||
let entry = self.entries.get(self.selected_entry?)?.status_entry()?;
|
||||
let workspace = self.workspace.upgrade()?;
|
||||
let git_repo = self.active_repository.as_ref()?;
|
||||
|
||||
if let Some(project_diff) = workspace.read(cx).active_item_as::<ProjectDiff>(cx) {
|
||||
if let Some(project_path) = project_diff.read(cx).active_path(cx) {
|
||||
if Some(&entry.repo_path)
|
||||
== git_repo
|
||||
.read(cx)
|
||||
.project_path_to_repo_path(&project_path)
|
||||
.as_ref()
|
||||
{
|
||||
project_diff.focus_handle(cx).focus(window);
|
||||
return None;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
self.workspace
|
||||
.update(cx, |workspace, cx| {
|
||||
ProjectDiff::deploy_at(workspace, Some(entry.clone()), window, cx);
|
||||
})
|
||||
.ok()
|
||||
.ok();
|
||||
self.focus_handle.focus(window);
|
||||
|
||||
Some(())
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2456,7 +2475,7 @@ impl GitPanel {
|
||||
ix: usize,
|
||||
entry: &GitStatusEntry,
|
||||
has_write_access: bool,
|
||||
_: &Window,
|
||||
window: &Window,
|
||||
cx: &Context<Self>,
|
||||
) -> AnyElement {
|
||||
let display_name = entry
|
||||
@@ -2548,6 +2567,10 @@ impl GitPanel {
|
||||
.h(self.list_item_height())
|
||||
.w_full()
|
||||
.items_center()
|
||||
.border_1()
|
||||
.when(selected && self.focus_handle.is_focused(window), |el| {
|
||||
el.border_color(cx.theme().colors().border_focused)
|
||||
})
|
||||
.px(rems(0.75)) // ~12px
|
||||
.overflow_hidden()
|
||||
.flex_none()
|
||||
@@ -2563,6 +2586,7 @@ impl GitPanel {
|
||||
this.open_file(&Default::default(), window, cx)
|
||||
} else {
|
||||
this.open_diff(&Default::default(), window, cx);
|
||||
this.focus_handle.focus(window);
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user