From aca35ea76f3df15ec68fd07959d939f5e7a78a6c Mon Sep 17 00:00:00 2001 From: Ogulcan Celik Date: Thu, 18 Jun 2026 00:50:33 +0300 Subject: fix: scope image paste shortcut to remote refs #647 --- src/config.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src/config.rs') 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, 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> { let (prefix_diag, prefix, keybind_diags, keybinds) = self.validated_keybinds(); let diagnostics: Vec = 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); + } } -- cgit v1.2.3