diff options
Diffstat (limited to 'src/app')
| -rw-r--r-- | src/app/input/mod.rs | 21 | ||||
| -rw-r--r-- | src/app/input/modal.rs | 12 | ||||
| -rw-r--r-- | src/app/input/settings.rs | 24 | ||||
| -rw-r--r-- | src/app/mod.rs | 2 | ||||
| -rw-r--r-- | src/app/runtime.rs | 9 | ||||
| -rw-r--r-- | src/app/state.rs | 9 |
6 files changed, 42 insertions, 35 deletions
diff --git a/src/app/input/mod.rs b/src/app/input/mod.rs index 56ad09a9..aa607c78 100644 --- a/src/app/input/mod.rs +++ b/src/app/input/mod.rs @@ -92,10 +92,13 @@ impl App { pub(crate) fn handle_onboarding_key(&mut self, key: KeyEvent) { match key.code { KeyCode::Right | KeyCode::Char('l') => self.open_settings_from_onboarding(), - _ => match modal_action_from_key(&key, ONBOARDING_WELCOME_ACTIONS) { - Some(ModalAction::Continue) => self.open_settings_from_onboarding(), - _ => {} - }, + _ => { + if let Some(ModalAction::Continue) = + modal_action_from_key(&key, ONBOARDING_WELCOME_ACTIONS) + { + self.open_settings_from_onboarding(); + } + } } } @@ -116,10 +119,12 @@ impl App { notes.scroll = max_scroll; } } - _ => match modal_action_from_key(&key, RELEASE_NOTES_ACTIONS) { - Some(ModalAction::Close) => self.dismiss_release_notes(), - _ => {} - }, + _ => { + if let Some(ModalAction::Close) = modal_action_from_key(&key, RELEASE_NOTES_ACTIONS) + { + self.dismiss_release_notes(); + } + } } } diff --git a/src/app/input/modal.rs b/src/app/input/modal.rs index 998bb69b..a76576bf 100644 --- a/src/app/input/modal.rs +++ b/src/app/input/modal.rs @@ -261,13 +261,11 @@ pub(super) fn apply_rename_action(state: &mut AppState, action: ModalAction) { state.name_input.trim().to_string() }; match state.mode { - Mode::RenameWorkspace if !state.workspaces.is_empty() => { - if !new_name.is_empty() { - let workspace_id = state.workspaces[state.selected].id.clone(); - state.workspaces[state.selected].set_custom_name(new_name); - crate::logging::workspace_renamed(&workspace_id); - state.mark_session_dirty(); - } + Mode::RenameWorkspace if !state.workspaces.is_empty() && !new_name.is_empty() => { + let workspace_id = state.workspaces[state.selected].id.clone(); + state.workspaces[state.selected].set_custom_name(new_name); + crate::logging::workspace_renamed(&workspace_id); + state.mark_session_dirty(); } Mode::RenameTab if state.creating_new_tab => { state.request_new_tab = true; diff --git a/src/app/input/settings.rs b/src/app/input/settings.rs index 2c92bc63..67144a28 100644 --- a/src/app/input/settings.rs +++ b/src/app/input/settings.rs @@ -10,6 +10,8 @@ use crate::{ }; #[derive(Debug, Clone, PartialEq, Eq)] +// The shared `Save` verb is semantic: these actions persist settings. +#[allow(clippy::enum_variant_names)] pub(super) enum SettingsAction { SaveTheme(String), SaveSound(bool), @@ -135,10 +137,13 @@ pub(super) fn update_settings_state(state: &mut AppState, key: KeyEvent) -> Opti state.settings.section = SettingsSection::Theme; state.settings.list.selected = current_theme_index(&state.theme_name); } - _ => match super::modal::modal_action_from_key(&key, super::modal::SETTINGS_ACTIONS) { - Some(super::modal::ModalAction::Close) => cancel_settings(state), - _ => {} - }, + _ => { + if let Some(super::modal::ModalAction::Close) = + super::modal::modal_action_from_key(&key, super::modal::SETTINGS_ACTIONS) + { + cancel_settings(state); + } + } }, SettingsSection::Toast => match key.code { KeyCode::Up | KeyCode::Char('k') => state.settings.list.move_prev(), @@ -155,10 +160,13 @@ pub(super) fn update_settings_state(state: &mut AppState, key: KeyEvent) -> Opti state.settings.section = SettingsSection::Theme; state.settings.list.selected = current_theme_index(&state.theme_name); } - _ => match super::modal::modal_action_from_key(&key, super::modal::SETTINGS_ACTIONS) { - Some(super::modal::ModalAction::Close) => cancel_settings(state), - _ => {} - }, + _ => { + if let Some(super::modal::ModalAction::Close) = + super::modal::modal_action_from_key(&key, super::modal::SETTINGS_ACTIONS) + { + cancel_settings(state); + } + } }, } diff --git a/src/app/mod.rs b/src/app/mod.rs index 1ea315cf..60e38f5b 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -351,7 +351,7 @@ impl App { toast_config: config.ui.toast.clone(), keybinds: config.keybinds(), spinner_tick: 0, - palette: resolve_palette(&config), + palette: resolve_palette(config), theme_name: config .theme .name diff --git a/src/app/runtime.rs b/src/app/runtime.rs index a4e93d3b..3c67c306 100644 --- a/src/app/runtime.rs +++ b/src/app/runtime.rs @@ -229,10 +229,11 @@ impl App { } pub(crate) fn start_git_status_refresh_if_due(&mut self, now: Instant) { - if !self - .git_refresh_deadline() - .is_some_and(|deadline| now >= deadline) - { + let Some(deadline) = self.git_refresh_deadline() else { + return; + }; + + if now < deadline { return; } diff --git a/src/app/state.rs b/src/app/state.rs index f7c4daa1..134d86bd 100644 --- a/src/app/state.rs +++ b/src/app/state.rs @@ -391,18 +391,13 @@ pub enum Mode { KeybindHelp, } -#[derive(Debug, Clone, Copy, PartialEq, Eq, serde::Serialize, serde::Deserialize)] +#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)] pub enum AgentPanelScope { CurrentWorkspace, + #[default] AllWorkspaces, } -impl Default for AgentPanelScope { - fn default() -> Self { - Self::AllWorkspaces - } -} - // --------------------------------------------------------------------------- // Settings UI state // --------------------------------------------------------------------------- |
