Skip to content

Commit a05d049

Browse files
committed
fix split false
1 parent 943ca9b commit a05d049

File tree

2 files changed

+68
-46
lines changed

2 files changed

+68
-46
lines changed

src/buffer/channel.rs

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ pub(crate) mod nick_list {
424424
use crate::widget::{Element, selectable_text};
425425
use crate::{Theme, font, theme};
426426

427-
pub fn view<'a>(
427+
pub fn content<'a>(
428428
server: &'a Server,
429429
prefix: &'a [isupport::PrefixMap],
430430
channel: &'a target::Channel,
@@ -453,7 +453,7 @@ pub(crate) mod nick_list {
453453
}
454454
};
455455

456-
let content = column(users.into_iter().flatten().map(|user| {
456+
column(users.into_iter().flatten().map(|user| {
457457
let content = selectable_text(
458458
user.display(nicklist_config.show_access_levels, None),
459459
)
@@ -485,14 +485,27 @@ pub(crate) mod nick_list {
485485
theme,
486486
&config.buffer.channel.nicklist.click,
487487
)
488-
}));
489-
490-
Scrollable::new(content)
491-
.direction(scrollable::Direction::Vertical(
492-
scrollable::Scrollbar::new().width(1).scroller_width(1),
493-
))
494-
.width(Length::Shrink)
495-
.style(theme::scrollable::hidden)
496-
.into()
488+
}))
489+
.into()
490+
}
491+
492+
pub fn view<'a>(
493+
server: &'a Server,
494+
prefix: &'a [isupport::PrefixMap],
495+
channel: &'a target::Channel,
496+
users: Option<&'a ChannelUsers>,
497+
our_user: Option<&'a User>,
498+
config: &'a Config,
499+
theme: &'a Theme,
500+
) -> Element<'a, Message> {
501+
Scrollable::new(content(
502+
server, prefix, channel, users, our_user, config, theme,
503+
))
504+
.direction(scrollable::Direction::Vertical(
505+
scrollable::Scrollbar::new().width(1).scroller_width(1),
506+
))
507+
.width(Length::Shrink)
508+
.style(theme::scrollable::hidden)
509+
.into()
497510
}
498511
}

src/screen/dashboard/sidebar.rs

Lines changed: 44 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -576,52 +576,61 @@ impl Sidebar {
576576

577577
match config.sidebar.position {
578578
sidebar::Position::Left | sidebar::Position::Right => {
579-
let nicklist: Option<Element<'a, Message>> = if config
580-
.sidebar
581-
.show_nicklist
582-
&& !self.nicklist_hidden
583-
{
584-
focused_channel_nicklist(
579+
let show_nicklist =
580+
config.sidebar.show_nicklist && !self.nicklist_hidden;
581+
582+
let direction = scrollable::Direction::Vertical(
583+
scrollable::Scrollbar::default()
584+
.width(config.sidebar.scrollbar.width)
585+
.scroller_width(
586+
config.sidebar.scrollbar.scroller_width,
587+
),
588+
);
589+
590+
let mut nicklist: Option<Element<'a, Message>> = None;
591+
let mut buflist_content =
592+
Column::with_children(buffers).spacing(0);
593+
594+
if show_nicklist
595+
&& let Some(list) = focused_channel_nicklist(
585596
panes, focus, clients, config, theme, width,
586597
)
587-
.map(|list| {
588-
container(list)
589-
.padding([0, 2])
590-
.height(if config.sidebar.split {
591-
Length::FillPortion(
598+
{
599+
if config.sidebar.split {
600+
let scrollable = Scrollable::new(list)
601+
.direction(direction)
602+
.width(Length::Shrink);
603+
604+
nicklist = Some(
605+
container(scrollable)
606+
.padding([0, 2])
607+
.height(Length::FillPortion(
592608
config.sidebar.nicklist_space,
593-
)
594-
} else {
595-
Length::Fill
596-
})
597-
.into()
598-
})
599-
} else {
600-
None
601-
};
609+
))
610+
.into(),
611+
);
612+
} else {
613+
buflist_content = buflist_content
614+
.push(container(list).padding([0, 2]));
615+
}
616+
}
602617

603618
let buflist_height =
604619
if config.sidebar.split && nicklist.is_some() {
605620
Length::FillPortion(config.sidebar.buflist_space)
606-
} else if nicklist.is_some() {
607-
Length::Shrink
608621
} else {
609622
Length::Fill
610623
};
611624

612-
let buflist = Scrollable::new(
613-
Column::with_children(buffers).spacing(0),
614-
)
615-
.direction(scrollable::Direction::Vertical(
616-
scrollable::Scrollbar::default()
617-
.width(config.sidebar.scrollbar.width)
618-
.scroller_width(
619-
config.sidebar.scrollbar.scroller_width,
620-
),
621-
))
622-
.height(buflist_height);
625+
let buflist = Scrollable::new(buflist_content)
626+
.direction(direction)
627+
.height(buflist_height);
623628

624-
let content = column![buflist, nicklist, user_menu_button,];
629+
let content = if show_nicklist && !config.sidebar.split {
630+
column![buflist, user_menu_button]
631+
} else {
632+
column![buflist, nicklist, user_menu_button]
633+
};
625634

626635
container(content)
627636
}
@@ -720,7 +729,7 @@ fn focused_channel_nicklist<'a>(
720729

721730
let users = clients.get_channel_users(server, channel);
722731
let prefix = clients.get_prefix(server);
723-
let list = crate::buffer::channel::nick_list::view(
732+
let list = crate::buffer::channel::nick_list::content(
724733
server, prefix, channel, users, None, config, theme,
725734
)
726735
.map(Message::Nicklist);

0 commit comments

Comments
 (0)