context_menu: Use when
instead of if-block (#24566)
See https://github.com/zed-industries/zed/pull/24562#issuecomment-2648343416 . Should have just added that to my original comment btw - sorry! CC @danilo-leal Release Notes: - N/A
This commit is contained in:
parent
72e1947025
commit
0fd2203665
1 changed files with 5 additions and 7 deletions
|
@ -671,18 +671,16 @@ impl Render for ContextMenu {
|
||||||
.when_some(
|
.when_some(
|
||||||
*toggle,
|
*toggle,
|
||||||
|list_item, (position, toggled)| {
|
|list_item, (position, toggled)| {
|
||||||
let contents = if toggled {
|
let contents =
|
||||||
div().flex_none().child(
|
div().flex_none().child(
|
||||||
Icon::new(IconName::Check)
|
Icon::new(IconName::Check)
|
||||||
.color(Color::Accent)
|
.color(Color::Accent)
|
||||||
.size(*icon_size)
|
.size(*icon_size)
|
||||||
)
|
)
|
||||||
} else {
|
.when(!toggled, |contents|
|
||||||
div().flex_none().child(
|
contents.invisible()
|
||||||
Icon::new(IconName::Check)
|
);
|
||||||
.size(*icon_size)
|
|
||||||
).invisible()
|
|
||||||
};
|
|
||||||
match position {
|
match position {
|
||||||
IconPosition::Start => {
|
IconPosition::Start => {
|
||||||
list_item
|
list_item
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue