Enforce rustfmt on CI & clean up some let-else format errors
This commit is contained in:
parent
2982a98d1c
commit
bda37ffb9c
3 changed files with 34 additions and 9 deletions
18
.github/workflows/ci.yml
vendored
18
.github/workflows/ci.yml
vendored
|
@ -17,6 +17,24 @@ env:
|
||||||
RUST_BACKTRACE: 1
|
RUST_BACKTRACE: 1
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
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:
|
tests:
|
||||||
name: Run tests
|
name: Run tests
|
||||||
runs-on:
|
runs-on:
|
||||||
|
|
|
@ -2244,7 +2244,9 @@ async fn test_propagate_saves_and_fs_changes(
|
||||||
});
|
});
|
||||||
|
|
||||||
// Edit the buffer as the host and concurrently save as guest B.
|
// 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));
|
buffer_a.update(cx_a, |buf, cx| buf.edit([(0..0, "hi-a, ")], None, cx));
|
||||||
save_b.await.unwrap();
|
save_b.await.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
@ -2917,7 +2919,10 @@ async fn test_buffer_conflict_after_save(
|
||||||
assert!(!buf.has_conflict());
|
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
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
cx_a.foreground().forbid_parking();
|
cx_a.foreground().forbid_parking();
|
||||||
|
|
|
@ -84,7 +84,7 @@ use std::{
|
||||||
};
|
};
|
||||||
pub use sum_tree::Bias;
|
pub use sum_tree::Bias;
|
||||||
use theme::{DiagnosticStyle, Theme};
|
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 workspace::{ItemNavHistory, ViewId, Workspace, WorkspaceId};
|
||||||
|
|
||||||
use crate::git::diff_hunk_to_display;
|
use crate::git::diff_hunk_to_display;
|
||||||
|
@ -4790,8 +4790,10 @@ impl Editor {
|
||||||
) {
|
) {
|
||||||
self.change_selections(Some(Autoscroll::fit()), cx, |s| {
|
self.change_selections(Some(Autoscroll::fit()), cx, |s| {
|
||||||
s.move_offsets_with(|snapshot, selection| {
|
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_length = usize::MAX;
|
||||||
let mut best_inside = false;
|
let mut best_inside = false;
|
||||||
let mut best_in_bracket_range = false;
|
let mut best_in_bracket_range = false;
|
||||||
|
@ -4801,17 +4803,17 @@ impl Editor {
|
||||||
let length = close.end() - open.start;
|
let length = close.end() - open.start;
|
||||||
let inside = selection.start >= open.end && selection.end <= *close.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());
|
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, skip
|
// If best is next to a bracket and current isn't, skip
|
||||||
if !in_bracket_range && best_in_bracket_range {
|
if !in_bracket_range && best_in_bracket_range {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prefer smaller lengths unless best is inside and current isn't
|
// Prefer smaller lengths unless best is inside and current isn't
|
||||||
if length > best_length && (best_inside || !inside) {
|
if length > best_length && (best_inside || !inside) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
best_length = length;
|
best_length = length;
|
||||||
best_inside = inside;
|
best_inside = inside;
|
||||||
best_in_bracket_range = in_bracket_range;
|
best_in_bracket_range = in_bracket_range;
|
||||||
|
@ -4829,7 +4831,7 @@ impl Editor {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(destination) = best_destination {
|
if let Some(destination) = best_destination {
|
||||||
selection.collapse_to(destination, SelectionGoal::None);
|
selection.collapse_to(destination, SelectionGoal::None);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue