Cherry-picked git: Touch up amend UX (#35114) Follow-up to #26114 - Ensure that the previous commit message is filled in when toggling on amend mode from the context menu - Fix keybinding flicker in context menu Release Notes: - N/A Co-authored-by: Cole Miller <cole@zed.dev>
This commit is contained in:
parent
44c6382e13
commit
185122d74e
4 changed files with 37 additions and 26 deletions
|
@ -872,8 +872,6 @@
|
||||||
"tab": "git_panel::FocusEditor",
|
"tab": "git_panel::FocusEditor",
|
||||||
"shift-tab": "git_panel::FocusEditor",
|
"shift-tab": "git_panel::FocusEditor",
|
||||||
"escape": "git_panel::ToggleFocus",
|
"escape": "git_panel::ToggleFocus",
|
||||||
"ctrl-enter": "git::Commit",
|
|
||||||
"ctrl-shift-enter": "git::Amend",
|
|
||||||
"alt-enter": "menu::SecondaryConfirm",
|
"alt-enter": "menu::SecondaryConfirm",
|
||||||
"delete": ["git::RestoreFile", { "skip_prompt": false }],
|
"delete": ["git::RestoreFile", { "skip_prompt": false }],
|
||||||
"backspace": ["git::RestoreFile", { "skip_prompt": false }],
|
"backspace": ["git::RestoreFile", { "skip_prompt": false }],
|
||||||
|
@ -910,7 +908,9 @@
|
||||||
"ctrl-g backspace": "git::RestoreTrackedFiles",
|
"ctrl-g backspace": "git::RestoreTrackedFiles",
|
||||||
"ctrl-g shift-backspace": "git::TrashUntrackedFiles",
|
"ctrl-g shift-backspace": "git::TrashUntrackedFiles",
|
||||||
"ctrl-space": "git::StageAll",
|
"ctrl-space": "git::StageAll",
|
||||||
"ctrl-shift-space": "git::UnstageAll"
|
"ctrl-shift-space": "git::UnstageAll",
|
||||||
|
"ctrl-enter": "git::Commit",
|
||||||
|
"ctrl-shift-enter": "git::Amend"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -950,8 +950,6 @@
|
||||||
"tab": "git_panel::FocusEditor",
|
"tab": "git_panel::FocusEditor",
|
||||||
"shift-tab": "git_panel::FocusEditor",
|
"shift-tab": "git_panel::FocusEditor",
|
||||||
"escape": "git_panel::ToggleFocus",
|
"escape": "git_panel::ToggleFocus",
|
||||||
"cmd-enter": "git::Commit",
|
|
||||||
"cmd-shift-enter": "git::Amend",
|
|
||||||
"backspace": ["git::RestoreFile", { "skip_prompt": false }],
|
"backspace": ["git::RestoreFile", { "skip_prompt": false }],
|
||||||
"delete": ["git::RestoreFile", { "skip_prompt": false }],
|
"delete": ["git::RestoreFile", { "skip_prompt": false }],
|
||||||
"cmd-backspace": ["git::RestoreFile", { "skip_prompt": true }],
|
"cmd-backspace": ["git::RestoreFile", { "skip_prompt": true }],
|
||||||
|
@ -1001,7 +999,9 @@
|
||||||
"ctrl-g backspace": "git::RestoreTrackedFiles",
|
"ctrl-g backspace": "git::RestoreTrackedFiles",
|
||||||
"ctrl-g shift-backspace": "git::TrashUntrackedFiles",
|
"ctrl-g shift-backspace": "git::TrashUntrackedFiles",
|
||||||
"cmd-ctrl-y": "git::StageAll",
|
"cmd-ctrl-y": "git::StageAll",
|
||||||
"cmd-ctrl-shift-y": "git::UnstageAll"
|
"cmd-ctrl-shift-y": "git::UnstageAll",
|
||||||
|
"cmd-enter": "git::Commit",
|
||||||
|
"cmd-shift-enter": "git::Amend"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -295,11 +295,13 @@ impl CommitModal {
|
||||||
IconPosition::Start,
|
IconPosition::Start,
|
||||||
Some(Box::new(Amend)),
|
Some(Box::new(Amend)),
|
||||||
{
|
{
|
||||||
let git_panel = git_panel_entity.clone();
|
let git_panel = git_panel_entity.downgrade();
|
||||||
move |window, cx| {
|
move |_, cx| {
|
||||||
git_panel.update(cx, |git_panel, cx| {
|
git_panel
|
||||||
git_panel.toggle_amend_pending(&Amend, window, cx);
|
.update(cx, |git_panel, cx| {
|
||||||
})
|
git_panel.toggle_amend_pending(cx);
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
@ -3054,6 +3054,7 @@ impl GitPanel {
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.menu({
|
.menu({
|
||||||
|
let git_panel = cx.entity();
|
||||||
let has_previous_commit = self.head_commit(cx).is_some();
|
let has_previous_commit = self.head_commit(cx).is_some();
|
||||||
let amend = self.amend_pending();
|
let amend = self.amend_pending();
|
||||||
let signoff = self.signoff_enabled;
|
let signoff = self.signoff_enabled;
|
||||||
|
@ -3070,7 +3071,16 @@ impl GitPanel {
|
||||||
amend,
|
amend,
|
||||||
IconPosition::Start,
|
IconPosition::Start,
|
||||||
Some(Box::new(Amend)),
|
Some(Box::new(Amend)),
|
||||||
move |window, cx| window.dispatch_action(Box::new(Amend), cx),
|
{
|
||||||
|
let git_panel = git_panel.downgrade();
|
||||||
|
move |_, cx| {
|
||||||
|
git_panel
|
||||||
|
.update(cx, |git_panel, cx| {
|
||||||
|
git_panel.toggle_amend_pending(cx);
|
||||||
|
})
|
||||||
|
.ok();
|
||||||
|
}
|
||||||
|
},
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.toggleable_entry(
|
.toggleable_entry(
|
||||||
|
@ -3441,9 +3451,11 @@ impl GitPanel {
|
||||||
.truncate(),
|
.truncate(),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.child(panel_button("Cancel").size(ButtonSize::Default).on_click(
|
.child(
|
||||||
cx.listener(|this, _, window, cx| this.toggle_amend_pending(&Amend, window, cx)),
|
panel_button("Cancel")
|
||||||
))
|
.size(ButtonSize::Default)
|
||||||
|
.on_click(cx.listener(|this, _, _, cx| this.set_amend_pending(false, cx))),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_previous_commit(&self, cx: &mut Context<Self>) -> Option<impl IntoElement> {
|
fn render_previous_commit(&self, cx: &mut Context<Self>) -> Option<impl IntoElement> {
|
||||||
|
@ -4204,17 +4216,8 @@ impl GitPanel {
|
||||||
|
|
||||||
pub fn set_amend_pending(&mut self, value: bool, cx: &mut Context<Self>) {
|
pub fn set_amend_pending(&mut self, value: bool, cx: &mut Context<Self>) {
|
||||||
self.amend_pending = value;
|
self.amend_pending = value;
|
||||||
cx.notify();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn toggle_amend_pending(
|
|
||||||
&mut self,
|
|
||||||
_: &Amend,
|
|
||||||
_window: &mut Window,
|
|
||||||
cx: &mut Context<Self>,
|
|
||||||
) {
|
|
||||||
self.set_amend_pending(!self.amend_pending, cx);
|
|
||||||
self.serialize(cx);
|
self.serialize(cx);
|
||||||
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn signoff_enabled(&self) -> bool {
|
pub fn signoff_enabled(&self) -> bool {
|
||||||
|
@ -4308,6 +4311,13 @@ impl GitPanel {
|
||||||
anchor: path,
|
anchor: path,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn toggle_amend_pending(&mut self, cx: &mut Context<Self>) {
|
||||||
|
self.set_amend_pending(!self.amend_pending, cx);
|
||||||
|
if self.amend_pending {
|
||||||
|
self.load_last_commit_message_if_empty(cx);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn current_language_model(cx: &Context<'_, GitPanel>) -> Option<Arc<dyn LanguageModel>> {
|
fn current_language_model(cx: &Context<'_, GitPanel>) -> Option<Arc<dyn LanguageModel>> {
|
||||||
|
@ -4352,7 +4362,6 @@ impl Render for GitPanel {
|
||||||
.on_action(cx.listener(Self::stage_range))
|
.on_action(cx.listener(Self::stage_range))
|
||||||
.on_action(cx.listener(GitPanel::commit))
|
.on_action(cx.listener(GitPanel::commit))
|
||||||
.on_action(cx.listener(GitPanel::amend))
|
.on_action(cx.listener(GitPanel::amend))
|
||||||
.on_action(cx.listener(GitPanel::toggle_amend_pending))
|
|
||||||
.on_action(cx.listener(GitPanel::toggle_signoff_enabled))
|
.on_action(cx.listener(GitPanel::toggle_signoff_enabled))
|
||||||
.on_action(cx.listener(Self::stage_all))
|
.on_action(cx.listener(Self::stage_all))
|
||||||
.on_action(cx.listener(Self::unstage_all))
|
.on_action(cx.listener(Self::unstage_all))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue