Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Enforce rustfmt on CI & clean up some let-else format errors
Juliabda37ffb9c86
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 5da8c8945e2..baa5da9bf71 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -17,6 +17,24 @@ env:RUST_BACKTRACE: 1jobs:+ rustfmt:+ name: Check formatting+ runs-on: self-hosted+ steps:+ - name: Install Rust+ run: |+ rustup set profile minimal+ rustup update stable++ - name: Checkout repo+ uses: actions/checkout@v2+ with:+ clean: false+ submodules: 'recursive'++ - name: cargo fmt+ run: cargo fmt --all -- --check+tests:name: Run testsruns-on:diff --git a/crates/collab/src/tests/integration_tests.rs b/crates/collab/src/tests/integration_tests.rsindex f2cb2eddbb5..2fc19b005b7 100644--- a/crates/collab/src/tests/integration_tests.rs+++ b/crates/collab/src/tests/integration_tests.rs@@ -2244,7 +2244,9 @@ async fn test_propagate_saves_and_fs_changes(});// Edit the buffer as the host and concurrently save as guest B.- let save_b = project_b.update(cx_b, |project, cx| project.save_buffer(buffer_b.clone(), cx));+ let save_b = project_b.update(cx_b, |project, cx| {+ project.save_buffer(buffer_b.clone(), cx)+ });buffer_a.update(cx_a, |buf, cx| buf.edit([(0..0, "hi-a, ")], None, cx));save_b.await.unwrap();assert_eq!(@@ -2917,7 +2919,10 @@ async fn test_buffer_conflict_after_save(assert!(!buf.has_conflict());});- project_b.update(cx_b, |project, cx| project.save_buffer(buffer_b.clone(), cx))+ project_b+ .update(cx_b, |project, cx| {+ project.save_buffer(buffer_b.clone(), cx)+ }).await.unwrap();cx_a.foreground().forbid_parking();diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rsindex f9d50019854..e06e7342171 100644--- a/crates/editor/src/editor.rs+++ b/crates/editor/src/editor.rs@@ -84,7 +84,7 @@ use std::{};pub use sum_tree::Bias;use theme::{DiagnosticStyle, Theme};-use util::{post_inc, ResultExt, TryFutureExt, RangeExt};+use util::{post_inc, RangeExt, ResultExt, TryFutureExt};use workspace::{ItemNavHistory, ViewId, Workspace, WorkspaceId};use crate::git::diff_hunk_to_display;@@ -4790,8 +4790,10 @@ impl Editor {) {self.change_selections(Some(Autoscroll::fit()), cx, |s| {s.move_offsets_with(|snapshot, selection| {- let Some(enclosing_bracket_ranges) = snapshot.enclosing_bracket_ranges(selection.start..selection.end) else { return; };-+ let Some(enclosing_bracket_ranges) = snapshot.enclosing_bracket_ranges(selection.start..selection.end) else {+ return;+ };+let mut best_length = usize::MAX;let mut best_inside = false;let mut best_in_bracket_range = false;@@ -4801,17 +4803,17 @@ impl Editor {let length = close.end() - open.start;let inside = selection.start >= open.end && selection.end <= *close.start();let in_bracket_range = open.to_inclusive().contains(&selection.head()) || close.contains(&selection.head());-+// If best is next to a bracket and current isn't, skipif !in_bracket_range && best_in_bracket_range {continue;}-+// Prefer smaller lengths unless best is inside and current isn'tif length > best_length && (best_inside || !inside) {continue;}-+best_length = length;best_inside = inside;best_in_bracket_range = in_bracket_range;@@ -4829,7 +4831,7 @@ impl Editor {}});}-+if let Some(destination) = best_destination {selection.collapse_to(destination, SelectionGoal::None);}