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

@ -570,23 +570,22 @@ impl GitStore {
cx: &mut Context<Self>,
) -> Task<Result<Entity<BufferDiff>>> {
let buffer_id = buffer.read(cx).remote_id();
if let Some(diff_state) = self.diffs.get(&buffer_id) {
if let Some(unstaged_diff) = diff_state
if let Some(diff_state) = self.diffs.get(&buffer_id)
&& let Some(unstaged_diff) = diff_state
.read(cx)
.unstaged_diff
.as_ref()
.and_then(|weak| weak.upgrade())
{
if let Some(task) =
diff_state.update(cx, |diff_state, _| diff_state.wait_for_recalculation())
{
if let Some(task) =
diff_state.update(cx, |diff_state, _| diff_state.wait_for_recalculation())
{
return cx.background_executor().spawn(async move {
task.await;
Ok(unstaged_diff)
});
}
return Task::ready(Ok(unstaged_diff));
return cx.background_executor().spawn(async move {
task.await;
Ok(unstaged_diff)
});
}
return Task::ready(Ok(unstaged_diff));
}
let Some((repo, repo_path)) =
@ -627,23 +626,22 @@ impl GitStore {
) -> Task<Result<Entity<BufferDiff>>> {
let buffer_id = buffer.read(cx).remote_id();
if let Some(diff_state) = self.diffs.get(&buffer_id) {
if let Some(uncommitted_diff) = diff_state
if let Some(diff_state) = self.diffs.get(&buffer_id)
&& let Some(uncommitted_diff) = diff_state
.read(cx)
.uncommitted_diff
.as_ref()
.and_then(|weak| weak.upgrade())
{
if let Some(task) =
diff_state.update(cx, |diff_state, _| diff_state.wait_for_recalculation())
{
if let Some(task) =
diff_state.update(cx, |diff_state, _| diff_state.wait_for_recalculation())
{
return cx.background_executor().spawn(async move {
task.await;
Ok(uncommitted_diff)
});
}
return Task::ready(Ok(uncommitted_diff));
return cx.background_executor().spawn(async move {
task.await;
Ok(uncommitted_diff)
});
}
return Task::ready(Ok(uncommitted_diff));
}
let Some((repo, repo_path)) =
@ -764,22 +762,21 @@ impl GitStore {
log::debug!("open conflict set");
let buffer_id = buffer.read(cx).remote_id();
if let Some(git_state) = self.diffs.get(&buffer_id) {
if let Some(conflict_set) = git_state
if let Some(git_state) = self.diffs.get(&buffer_id)
&& let Some(conflict_set) = git_state
.read(cx)
.conflict_set
.as_ref()
.and_then(|weak| weak.upgrade())
{
let conflict_set = conflict_set.clone();
let buffer_snapshot = buffer.read(cx).text_snapshot();
{
let conflict_set = conflict_set.clone();
let buffer_snapshot = buffer.read(cx).text_snapshot();
git_state.update(cx, |state, cx| {
let _ = state.reparse_conflict_markers(buffer_snapshot, cx);
});
git_state.update(cx, |state, cx| {
let _ = state.reparse_conflict_markers(buffer_snapshot, cx);
});
return conflict_set;
}
return conflict_set;
}
let is_unmerged = self
@ -1151,29 +1148,26 @@ impl GitStore {
for (buffer_id, diff) in self.diffs.iter() {
if let Some((buffer_repo, repo_path)) =
self.repository_and_path_for_buffer_id(*buffer_id, cx)
&& buffer_repo == repo
{
if buffer_repo == repo {
diff.update(cx, |diff, cx| {
if let Some(conflict_set) = &diff.conflict_set {
let conflict_status_changed =
conflict_set.update(cx, |conflict_set, cx| {
let has_conflict = repo_snapshot.has_conflict(&repo_path);
conflict_set.set_has_conflict(has_conflict, cx)
})?;
if conflict_status_changed {
let buffer_store = self.buffer_store.read(cx);
if let Some(buffer) = buffer_store.get(*buffer_id) {
let _ = diff.reparse_conflict_markers(
buffer.read(cx).text_snapshot(),
cx,
);
}
diff.update(cx, |diff, cx| {
if let Some(conflict_set) = &diff.conflict_set {
let conflict_status_changed =
conflict_set.update(cx, |conflict_set, cx| {
let has_conflict = repo_snapshot.has_conflict(&repo_path);
conflict_set.set_has_conflict(has_conflict, cx)
})?;
if conflict_status_changed {
let buffer_store = self.buffer_store.read(cx);
if let Some(buffer) = buffer_store.get(*buffer_id) {
let _ = diff
.reparse_conflict_markers(buffer.read(cx).text_snapshot(), cx);
}
}
anyhow::Ok(())
})
.ok();
}
}
anyhow::Ok(())
})
.ok();
}
}
cx.emit(GitStoreEvent::RepositoryUpdated(
@ -2231,13 +2225,13 @@ impl GitStore {
) -> Result<()> {
let buffer_id = BufferId::new(request.payload.buffer_id)?;
this.update(&mut cx, |this, cx| {
if let Some(diff_state) = this.diffs.get_mut(&buffer_id) {
if let Some(buffer) = this.buffer_store.read(cx).get(buffer_id) {
let buffer = buffer.read(cx).text_snapshot();
diff_state.update(cx, |diff_state, cx| {
diff_state.handle_base_texts_updated(buffer, request.payload, cx);
})
}
if let Some(diff_state) = this.diffs.get_mut(&buffer_id)
&& let Some(buffer) = this.buffer_store.read(cx).get(buffer_id)
{
let buffer = buffer.read(cx).text_snapshot();
diff_state.update(cx, |diff_state, cx| {
diff_state.handle_base_texts_updated(buffer, request.payload, cx);
})
}
})
}
@ -3533,14 +3527,13 @@ impl Repository {
let Some(project_path) = self.repo_path_to_project_path(path, cx) else {
continue;
};
if let Some(buffer) = buffer_store.get_by_path(&project_path) {
if buffer
if let Some(buffer) = buffer_store.get_by_path(&project_path)
&& buffer
.read(cx)
.file()
.map_or(false, |file| file.disk_state().exists())
{
save_futures.push(buffer_store.save_buffer(buffer, cx));
}
{
save_futures.push(buffer_store.save_buffer(buffer, cx));
}
}
})
@ -3600,14 +3593,13 @@ impl Repository {
let Some(project_path) = self.repo_path_to_project_path(path, cx) else {
continue;
};
if let Some(buffer) = buffer_store.get_by_path(&project_path) {
if buffer
if let Some(buffer) = buffer_store.get_by_path(&project_path)
&& buffer
.read(cx)
.file()
.map_or(false, |file| file.disk_state().exists())
{
save_futures.push(buffer_store.save_buffer(buffer, cx));
}
{
save_futures.push(buffer_store.save_buffer(buffer, cx));
}
}
})
@ -4421,14 +4413,13 @@ impl Repository {
}
if let Some(job) = jobs.pop_front() {
if let Some(current_key) = &job.key {
if jobs
if let Some(current_key) = &job.key
&& jobs
.iter()
.any(|other_job| other_job.key.as_ref() == Some(current_key))
{
continue;
}
}
(job.job)(state.clone(), cx).await;
} else if let Some(job) = job_rx.next().await {
jobs.push_back(job);
@ -4459,13 +4450,12 @@ impl Repository {
}
if let Some(job) = jobs.pop_front() {
if let Some(current_key) = &job.key {
if jobs
if let Some(current_key) = &job.key
&& jobs
.iter()
.any(|other_job| other_job.key.as_ref() == Some(current_key))
{
continue;
}
{
continue;
}
(job.job)(state.clone(), cx).await;
} else if let Some(job) = job_rx.next().await {
@ -4589,10 +4579,10 @@ impl Repository {
for (repo_path, status) in &*statuses.entries {
changed_paths.remove(repo_path);
if cursor.seek_forward(&PathTarget::Path(repo_path), Bias::Left) {
if cursor.item().is_some_and(|entry| entry.status == *status) {
continue;
}
if cursor.seek_forward(&PathTarget::Path(repo_path), Bias::Left)
&& cursor.item().is_some_and(|entry| entry.status == *status)
{
continue;
}
changed_path_statuses.push(Edit::Insert(StatusEntry {