Auto-fix clippy::collapsible_if violations (#36428)

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2025-08-19 15:27:24 +02:00 committed by GitHub
parent 9e8ec72bd5
commit 8f567383e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
281 changed files with 6628 additions and 7089 deletions

View file

@ -300,13 +300,12 @@ impl<'a> MarkdownParser<'a> {
if style != MarkdownHighlightStyle::default() && last_run_len < text.len() {
let mut new_highlight = true;
if let Some((last_range, last_style)) = highlights.last_mut() {
if last_range.end == last_run_len
&& last_style == &MarkdownHighlight::Style(style.clone())
{
last_range.end = text.len();
new_highlight = false;
}
if let Some((last_range, last_style)) = highlights.last_mut()
&& last_range.end == last_run_len
&& last_style == &MarkdownHighlight::Style(style.clone())
{
last_range.end = text.len();
new_highlight = false;
}
if new_highlight {
highlights.push((
@ -579,10 +578,10 @@ impl<'a> MarkdownParser<'a> {
}
} else {
let block = self.parse_block().await;
if let Some(block) = block {
if let Some(list_item) = items_stack.last_mut() {
list_item.content.extend(block);
}
if let Some(block) = block
&& let Some(list_item) = items_stack.last_mut()
{
list_item.content.extend(block);
}
}
}

View file

@ -151,10 +151,9 @@ impl MarkdownPreviewView {
if let Some(editor) = workspace
.active_item(cx)
.and_then(|item| item.act_as::<Editor>(cx))
&& Self::is_markdown_file(&editor, cx)
{
if Self::is_markdown_file(&editor, cx) {
return Some(editor);
}
return Some(editor);
}
None
}
@ -243,32 +242,30 @@ impl MarkdownPreviewView {
window: &mut Window,
cx: &mut Context<Self>,
) {
if let Some(item) = active_item {
if item.item_id() != cx.entity_id() {
if let Some(editor) = item.act_as::<Editor>(cx) {
if Self::is_markdown_file(&editor, cx) {
self.set_editor(editor, window, cx);
}
}
}
if let Some(item) = active_item
&& item.item_id() != cx.entity_id()
&& let Some(editor) = item.act_as::<Editor>(cx)
&& Self::is_markdown_file(&editor, cx)
{
self.set_editor(editor, window, cx);
}
}
pub fn is_markdown_file<V>(editor: &Entity<Editor>, cx: &mut Context<V>) -> bool {
let buffer = editor.read(cx).buffer().read(cx);
if let Some(buffer) = buffer.as_singleton() {
if let Some(language) = buffer.read(cx).language() {
return language.name() == "Markdown".into();
}
if let Some(buffer) = buffer.as_singleton()
&& let Some(language) = buffer.read(cx).language()
{
return language.name() == "Markdown".into();
}
false
}
fn set_editor(&mut self, editor: Entity<Editor>, window: &mut Window, cx: &mut Context<Self>) {
if let Some(active) = &self.active_editor {
if active.editor == editor {
return;
}
if let Some(active) = &self.active_editor
&& active.editor == editor
{
return;
}
let subscription = cx.subscribe_in(
@ -552,21 +549,20 @@ impl Render for MarkdownPreviewView {
.group("markdown-block")
.on_click(cx.listener(
move |this, event: &ClickEvent, window, cx| {
if event.click_count() == 2 {
if let Some(source_range) = this
if event.click_count() == 2
&& let Some(source_range) = this
.contents
.as_ref()
.and_then(|c| c.children.get(ix))
.and_then(|block: &ParsedMarkdownElement| {
block.source_range()
})
{
this.move_cursor_to_block(
window,
cx,
source_range.start..source_range.start,
);
}
{
this.move_cursor_to_block(
window,
cx,
source_range.start..source_range.start,
);
}
},
))