Auto-fix clippy::collapsible_if violations (#36428)
Release Notes: - N/A
This commit is contained in:
parent
9e8ec72bd5
commit
8f567383e4
281 changed files with 6628 additions and 7089 deletions
|
@ -340,27 +340,26 @@ impl Markdown {
|
|||
}
|
||||
|
||||
for (range, event) in &events {
|
||||
if let MarkdownEvent::Start(MarkdownTag::Image { dest_url, .. }) = event {
|
||||
if let Some(data_url) = dest_url.strip_prefix("data:") {
|
||||
let Some((mime_info, data)) = data_url.split_once(',') else {
|
||||
continue;
|
||||
};
|
||||
let Some((mime_type, encoding)) = mime_info.split_once(';') else {
|
||||
continue;
|
||||
};
|
||||
let Some(format) = ImageFormat::from_mime_type(mime_type) else {
|
||||
continue;
|
||||
};
|
||||
let is_base64 = encoding == "base64";
|
||||
if is_base64 {
|
||||
if let Some(bytes) = base64::prelude::BASE64_STANDARD
|
||||
.decode(data)
|
||||
.log_with_level(Level::Debug)
|
||||
{
|
||||
let image = Arc::new(Image::from_bytes(format, bytes));
|
||||
images_by_source_offset.insert(range.start, image);
|
||||
}
|
||||
}
|
||||
if let MarkdownEvent::Start(MarkdownTag::Image { dest_url, .. }) = event
|
||||
&& let Some(data_url) = dest_url.strip_prefix("data:")
|
||||
{
|
||||
let Some((mime_info, data)) = data_url.split_once(',') else {
|
||||
continue;
|
||||
};
|
||||
let Some((mime_type, encoding)) = mime_info.split_once(';') else {
|
||||
continue;
|
||||
};
|
||||
let Some(format) = ImageFormat::from_mime_type(mime_type) else {
|
||||
continue;
|
||||
};
|
||||
let is_base64 = encoding == "base64";
|
||||
if is_base64
|
||||
&& let Some(bytes) = base64::prelude::BASE64_STANDARD
|
||||
.decode(data)
|
||||
.log_with_level(Level::Debug)
|
||||
{
|
||||
let image = Arc::new(Image::from_bytes(format, bytes));
|
||||
images_by_source_offset.insert(range.start, image);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -659,13 +658,13 @@ impl MarkdownElement {
|
|||
let rendered_text = rendered_text.clone();
|
||||
move |markdown, event: &MouseUpEvent, phase, window, cx| {
|
||||
if phase.bubble() {
|
||||
if let Some(pressed_link) = markdown.pressed_link.take() {
|
||||
if Some(&pressed_link) == rendered_text.link_for_position(event.position) {
|
||||
if let Some(open_url) = on_open_url.as_ref() {
|
||||
open_url(pressed_link.destination_url, window, cx);
|
||||
} else {
|
||||
cx.open_url(&pressed_link.destination_url);
|
||||
}
|
||||
if let Some(pressed_link) = markdown.pressed_link.take()
|
||||
&& Some(&pressed_link) == rendered_text.link_for_position(event.position)
|
||||
{
|
||||
if let Some(open_url) = on_open_url.as_ref() {
|
||||
open_url(pressed_link.destination_url, window, cx);
|
||||
} else {
|
||||
cx.open_url(&pressed_link.destination_url);
|
||||
}
|
||||
}
|
||||
} else if markdown.selection.pending {
|
||||
|
@ -758,10 +757,10 @@ impl Element for MarkdownElement {
|
|||
let mut current_img_block_range: Option<Range<usize>> = None;
|
||||
for (range, event) in parsed_markdown.events.iter() {
|
||||
// Skip alt text for images that rendered
|
||||
if let Some(current_img_block_range) = ¤t_img_block_range {
|
||||
if current_img_block_range.end > range.end {
|
||||
continue;
|
||||
}
|
||||
if let Some(current_img_block_range) = ¤t_img_block_range
|
||||
&& current_img_block_range.end > range.end
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
match event {
|
||||
|
@ -1696,10 +1695,10 @@ impl RenderedText {
|
|||
while let Some(line) = lines.next() {
|
||||
let line_bounds = line.layout.bounds();
|
||||
if position.y > line_bounds.bottom() {
|
||||
if let Some(next_line) = lines.peek() {
|
||||
if position.y < next_line.layout.bounds().top() {
|
||||
return Err(line.source_end);
|
||||
}
|
||||
if let Some(next_line) = lines.peek()
|
||||
&& position.y < next_line.layout.bounds().top()
|
||||
{
|
||||
return Err(line.source_end);
|
||||
}
|
||||
|
||||
continue;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue