parent
28f33d0103
commit
5d66c3db85
1 changed files with 17 additions and 5 deletions
|
@ -270,6 +270,8 @@ impl Drop for RemoteOperationGuard {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MAX_PANEL_EDITOR_LINES: usize = 6;
|
||||||
|
|
||||||
pub(crate) fn commit_message_editor(
|
pub(crate) fn commit_message_editor(
|
||||||
commit_message_buffer: Entity<Buffer>,
|
commit_message_buffer: Entity<Buffer>,
|
||||||
placeholder: Option<&str>,
|
placeholder: Option<&str>,
|
||||||
|
@ -279,7 +281,7 @@ pub(crate) fn commit_message_editor(
|
||||||
cx: &mut Context<'_, Editor>,
|
cx: &mut Context<'_, Editor>,
|
||||||
) -> Editor {
|
) -> Editor {
|
||||||
let buffer = cx.new(|cx| MultiBuffer::singleton(commit_message_buffer, cx));
|
let buffer = cx.new(|cx| MultiBuffer::singleton(commit_message_buffer, cx));
|
||||||
let max_lines = if in_panel { 6 } else { 18 };
|
let max_lines = if in_panel { MAX_PANEL_EDITOR_LINES } else { 18 };
|
||||||
let mut commit_editor = Editor::new(
|
let mut commit_editor = Editor::new(
|
||||||
EditorMode::AutoHeight { max_lines },
|
EditorMode::AutoHeight { max_lines },
|
||||||
buffer,
|
buffer,
|
||||||
|
@ -2590,8 +2592,12 @@ impl GitPanel {
|
||||||
let branch = active_repository.read(cx).current_branch().cloned();
|
let branch = active_repository.read(cx).current_branch().cloned();
|
||||||
|
|
||||||
let footer_size = px(32.);
|
let footer_size = px(32.);
|
||||||
let gap = px(8.0);
|
let gap = px(9.0);
|
||||||
let max_height = window.line_height() * 5. + gap + footer_size;
|
let max_height = panel_editor_style
|
||||||
|
.text
|
||||||
|
.line_height_in_pixels(window.rem_size())
|
||||||
|
* MAX_PANEL_EDITOR_LINES
|
||||||
|
+ gap;
|
||||||
|
|
||||||
let git_panel = cx.entity().clone();
|
let git_panel = cx.entity().clone();
|
||||||
let display_name = SharedString::from(Arc::from(
|
let display_name = SharedString::from(Arc::from(
|
||||||
|
@ -2600,6 +2606,9 @@ impl GitPanel {
|
||||||
.display_name(project, cx)
|
.display_name(project, cx)
|
||||||
.trim_end_matches("/"),
|
.trim_end_matches("/"),
|
||||||
));
|
));
|
||||||
|
let editor_is_long = self.commit_editor.update(cx, |editor, cx| {
|
||||||
|
editor.max_point(cx).row().0 >= MAX_PANEL_EDITOR_LINES as u32
|
||||||
|
});
|
||||||
|
|
||||||
let footer = v_flex()
|
let footer = v_flex()
|
||||||
.child(PanelRepoFooter::new(
|
.child(PanelRepoFooter::new(
|
||||||
|
@ -2612,11 +2621,10 @@ impl GitPanel {
|
||||||
panel_editor_container(window, cx)
|
panel_editor_container(window, cx)
|
||||||
.id("commit-editor-container")
|
.id("commit-editor-container")
|
||||||
.relative()
|
.relative()
|
||||||
.h(max_height)
|
|
||||||
.w_full()
|
.w_full()
|
||||||
|
.h(max_height + footer_size)
|
||||||
.border_t_1()
|
.border_t_1()
|
||||||
.border_color(cx.theme().colors().border_variant)
|
.border_color(cx.theme().colors().border_variant)
|
||||||
.bg(cx.theme().colors().editor_background)
|
|
||||||
.cursor_text()
|
.cursor_text()
|
||||||
.on_click(cx.listener(move |this, _: &ClickEvent, window, cx| {
|
.on_click(cx.listener(move |this, _: &ClickEvent, window, cx| {
|
||||||
window.focus(&this.commit_editor.focus_handle(cx));
|
window.focus(&this.commit_editor.focus_handle(cx));
|
||||||
|
@ -2624,6 +2632,10 @@ impl GitPanel {
|
||||||
.child(
|
.child(
|
||||||
h_flex()
|
h_flex()
|
||||||
.id("commit-footer")
|
.id("commit-footer")
|
||||||
|
.border_t_1()
|
||||||
|
.when(editor_is_long, |el| {
|
||||||
|
el.border_color(cx.theme().colors().border_variant)
|
||||||
|
})
|
||||||
.absolute()
|
.absolute()
|
||||||
.bottom_0()
|
.bottom_0()
|
||||||
.left_0()
|
.left_0()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue