aboutsummaryrefslogtreecommitdiff
path: root/src/config.rs
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-05-21 15:17:37 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-05-21 15:17:37 +0300
commit06bcd06a17be3bd242e2b8230dd9b803b1969f3c (patch)
treeecec609d7cccd346a81d749c63b094ce3a97a11f /src/config.rs
parentdde0ddb3aec0522f2bc4c6fa1cb7d25f99fc8403 (diff)
feat: use local keybindings for remote attach
Diffstat (limited to 'src/config.rs')
-rw-r--r--src/config.rs44
1 files changed, 43 insertions, 1 deletions
diff --git a/src/config.rs b/src/config.rs
index 48ebb8f6..b6406874 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -19,7 +19,7 @@ pub use self::{
},
model::{
validated_sidebar_bounds, AgentPanelScopeConfig, Config, ConfigReloadReport,
- ConfigReloadStatus, ToastConfig, ToastDelivery,
+ ConfigReloadStatus, KeysConfig, ToastConfig, ToastDelivery,
},
sound::SoundConfig,
theme::{parse_color, CustomThemeColors, ThemeConfig},
@@ -67,4 +67,46 @@ impl Config {
Err(diagnostics)
}
}
+
+ pub(crate) fn local_keybindings_profile_toml(&self) -> Result<String, toml::ser::Error> {
+ let mut keys = self.keys.clone();
+ keys.command.clear();
+
+ #[derive(serde::Serialize)]
+ struct KeysProfile {
+ keys: KeysConfig,
+ }
+
+ toml::to_string_pretty(&KeysProfile { keys })
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn local_keybindings_profile_includes_defaults_and_excludes_commands() {
+ let config: Config = toml::from_str(
+ r#"
+[keys]
+prefix = "ctrl+a"
+new_tab = "prefix+t"
+
+[[keys.command]]
+key = "prefix+g"
+command = "lazygit"
+"#,
+ )
+ .unwrap();
+
+ let profile = config.local_keybindings_profile_toml().unwrap();
+ assert!(profile.contains("[keys]"));
+ assert!(profile.contains("prefix = \"ctrl+a\""));
+ assert!(profile.contains("new_tab = \"prefix+t\""));
+ assert!(profile.contains("next_tab = \"prefix+n\""));
+ assert!(!profile.contains("lazygit"));
+ assert!(!profile.contains("command ="));
+ assert!(!profile.contains("[[keys.command]]"));
+ }
}