diff options
| author | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-18 00:50:33 +0300 |
|---|---|---|
| committer | Ogulcan Celik <ogulcancelik@gmail.com> | 2026-06-18 01:56:26 +0300 |
| commit | aca35ea76f3df15ec68fd07959d939f5e7a78a6c (patch) | |
| tree | b9993804ebbed375dca301a762a681a1cad3b713 /src/config.rs | |
| parent | 54490254f70469cd154ee630bc4bec84da178f0c (diff) | |
fix: scope image paste shortcut to remote
refs #647
Diffstat (limited to 'src/config.rs')
| -rw-r--r-- | src/config.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/config.rs b/src/config.rs index bf5fceb4..003178ab 100644 --- a/src/config.rs +++ b/src/config.rs @@ -65,10 +65,21 @@ impl Config { prefix_diag .into_iter() .chain(keybind_diags) + .chain(self.remote_image_paste_key().err()) .chain(self.ui.sound.diagnostics()) .collect() } + pub(crate) fn remote_image_paste_key(&self) -> Result<Option<(KeyCode, KeyModifiers)>, String> { + let raw = self.keys.remote_image_paste.trim(); + if raw.is_empty() { + return Ok(None); + } + parse_key_combo(raw).map(Some).ok_or_else(|| { + format!("invalid keybinding: keys.remote_image_paste = {raw:?}; disabling binding") + }) + } + pub fn live_keybinds(&self) -> Result<LiveKeybindConfig, Vec<String>> { let (prefix_diag, prefix, keybind_diags, keybinds) = self.validated_keybinds(); let diagnostics: Vec<String> = prefix_diag.into_iter().chain(keybind_diags).collect(); @@ -120,4 +131,19 @@ command = "lazygit" assert!(!profile.contains("command =")); assert!(!profile.contains("[[keys.command]]")); } + + #[test] + fn remote_image_paste_key_defaults_to_ctrl_v() { + let config = Config::default(); + assert_eq!( + config.remote_image_paste_key().unwrap(), + Some((KeyCode::Char('v'), KeyModifiers::CONTROL)) + ); + } + + #[test] + fn remote_image_paste_key_can_be_disabled() { + let config: Config = toml::from_str("[keys]\nremote_image_paste = ''\n").unwrap(); + assert_eq!(config.remote_image_paste_key().unwrap(), None); + } } |
