Move git hunk controls to the left side (#18460)
 Release Notes: - N/A
This commit is contained in:
parent
1c5be9de4e
commit
689da9d0b1
1 changed files with 64 additions and 67 deletions
|
@ -513,49 +513,7 @@ impl Editor {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
),
|
)
|
||||||
)
|
|
||||||
.child(
|
|
||||||
h_flex()
|
|
||||||
.gap_2()
|
|
||||||
.pr_6()
|
|
||||||
.child({
|
|
||||||
let focus = editor.focus_handle(cx);
|
|
||||||
PopoverMenu::new("hunk-controls-dropdown")
|
|
||||||
.trigger(
|
|
||||||
IconButton::new(
|
|
||||||
"toggle_editor_selections_icon",
|
|
||||||
IconName::EllipsisVertical,
|
|
||||||
)
|
|
||||||
.shape(IconButtonShape::Square)
|
|
||||||
.icon_size(IconSize::Small)
|
|
||||||
.style(ButtonStyle::Subtle)
|
|
||||||
.selected(
|
|
||||||
hunk_controls_menu_handle.is_deployed(),
|
|
||||||
)
|
|
||||||
.when(
|
|
||||||
!hunk_controls_menu_handle.is_deployed(),
|
|
||||||
|this| {
|
|
||||||
this.tooltip(|cx| {
|
|
||||||
Tooltip::text("Hunk Controls", cx)
|
|
||||||
})
|
|
||||||
},
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.anchor(AnchorCorner::TopRight)
|
|
||||||
.with_handle(hunk_controls_menu_handle)
|
|
||||||
.menu(move |cx| {
|
|
||||||
let focus = focus.clone();
|
|
||||||
let menu =
|
|
||||||
ContextMenu::build(cx, move |menu, _| {
|
|
||||||
menu.context(focus.clone()).action(
|
|
||||||
"Discard All",
|
|
||||||
RevertFile.boxed_clone(),
|
|
||||||
)
|
|
||||||
});
|
|
||||||
Some(menu)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.child(
|
.child(
|
||||||
IconButton::new("discard", IconName::RotateCcw)
|
IconButton::new("discard", IconName::RotateCcw)
|
||||||
.shape(IconButtonShape::Square)
|
.shape(IconButtonShape::Square)
|
||||||
|
@ -601,31 +559,70 @@ impl Editor {
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.child(
|
.child({
|
||||||
IconButton::new("collapse", IconName::Close)
|
let focus = editor.focus_handle(cx);
|
||||||
.shape(IconButtonShape::Square)
|
PopoverMenu::new("hunk-controls-dropdown")
|
||||||
.icon_size(IconSize::Small)
|
.trigger(
|
||||||
.tooltip({
|
IconButton::new(
|
||||||
let focus_handle = editor.focus_handle(cx);
|
"toggle_editor_selections_icon",
|
||||||
move |cx| {
|
IconName::EllipsisVertical,
|
||||||
Tooltip::for_action_in(
|
)
|
||||||
"Collapse Hunk",
|
.shape(IconButtonShape::Square)
|
||||||
&ToggleHunkDiff,
|
.icon_size(IconSize::Small)
|
||||||
&focus_handle,
|
.style(ButtonStyle::Subtle)
|
||||||
cx,
|
.selected(
|
||||||
)
|
hunk_controls_menu_handle.is_deployed(),
|
||||||
}
|
)
|
||||||
})
|
.when(
|
||||||
.on_click({
|
!hunk_controls_menu_handle.is_deployed(),
|
||||||
let editor = editor.clone();
|
|this| {
|
||||||
let hunk = hunk.clone();
|
this.tooltip(|cx| {
|
||||||
move |_event, cx| {
|
Tooltip::text("Hunk Controls", cx)
|
||||||
editor.update(cx, |editor, cx| {
|
})
|
||||||
editor.toggle_hovered_hunk(&hunk, cx);
|
},
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.anchor(AnchorCorner::TopRight)
|
||||||
|
.with_handle(hunk_controls_menu_handle)
|
||||||
|
.menu(move |cx| {
|
||||||
|
let focus = focus.clone();
|
||||||
|
let menu =
|
||||||
|
ContextMenu::build(cx, move |menu, _| {
|
||||||
|
menu.context(focus.clone()).action(
|
||||||
|
"Discard All",
|
||||||
|
RevertFile.boxed_clone(),
|
||||||
|
)
|
||||||
});
|
});
|
||||||
}
|
Some(menu)
|
||||||
}),
|
})
|
||||||
),
|
}),
|
||||||
|
)
|
||||||
|
.child(
|
||||||
|
h_flex().gap_2().pr_6().child(
|
||||||
|
IconButton::new("collapse", IconName::Close)
|
||||||
|
.shape(IconButtonShape::Square)
|
||||||
|
.icon_size(IconSize::Small)
|
||||||
|
.tooltip({
|
||||||
|
let focus_handle = editor.focus_handle(cx);
|
||||||
|
move |cx| {
|
||||||
|
Tooltip::for_action_in(
|
||||||
|
"Collapse Hunk",
|
||||||
|
&ToggleHunkDiff,
|
||||||
|
&focus_handle,
|
||||||
|
cx,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.on_click({
|
||||||
|
let editor = editor.clone();
|
||||||
|
let hunk = hunk.clone();
|
||||||
|
move |_event, cx| {
|
||||||
|
editor.update(cx, |editor, cx| {
|
||||||
|
editor.toggle_hovered_hunk(&hunk, cx);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
.into_any_element()
|
.into_any_element()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue