From 8d7b92b1b1af4baf274a6e0cd674931de43dcf71 Mon Sep 17 00:00:00 2001 From: Chris Glass Date: Sat, 28 Feb 2026 22:39:27 +0100 Subject: [PATCH] Introduce a "cargo fmt" github action gate This should prevent non-fmt code from hitting the master branch. --- .github/workflows/rust-checks.yml | 26 ++++++++++++++++++++++++++ src/main.rs | 21 +++++++++++++-------- 2 files changed, 39 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/rust-checks.yml diff --git a/.github/workflows/rust-checks.yml b/.github/workflows/rust-checks.yml new file mode 100644 index 0000000..b29c7d4 --- /dev/null +++ b/.github/workflows/rust-checks.yml @@ -0,0 +1,26 @@ +name: Rust Checks + +on: + push: + branches: [master] + pull_request: + branches: [master] + +env: + CARGO_TERM_COLOR: always + +jobs: + fmt: + name: Rustfmt + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Rust + uses: dtolnay/rust-toolchain@stable + with: + components: rustfmt + + - name: Check formatting + run: cargo fmt --all -- --check diff --git a/src/main.rs b/src/main.rs index 4f4ed2f..edda04d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1526,11 +1526,13 @@ impl App { Some(colors) => { let current_pane = self.pane_model.focused(); if let Some(tab_model) = self.pane_model.active_mut() { - let (options, tab_title_override) = if let Some(profile) = profile_id_opt - .and_then(|profile_id| self.config.profiles.get(&profile_id)) + let (options, tab_title_override) = if let Some(profile) = + profile_id_opt + .and_then(|profile_id| self.config.profiles.get(&profile_id)) { // Merge profile and startup options, preferring startup options - let startup_options = self.startup_options.take().unwrap_or_default(); + let startup_options = + self.startup_options.take().unwrap_or_default(); let options = tty::Options { shell: startup_options.shell.or_else(|| { if let Some(mut args) = shlex::split(&profile.command) { @@ -1541,11 +1543,14 @@ impl App { } return None; }), - working_directory: startup_options.working_directory.or_else(|| { - (!profile.working_directory.is_empty()) - .then(|| profile.working_directory.clone().into()) - }), - drain_on_exit: startup_options.drain_on_exit || profile.drain_on_exit, + working_directory: startup_options.working_directory.or_else( + || { + (!profile.working_directory.is_empty()) + .then(|| profile.working_directory.clone().into()) + }, + ), + drain_on_exit: startup_options.drain_on_exit + || profile.drain_on_exit, ..startup_options }; let tab_title_override = if profile.tab_title.is_empty() {