From b6fa83d4822ddff9817b2199bbc4bf0bb2e78769 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paal=20=C3=98ye-Str=C3=B8mme?= Date: Sun, 17 May 2026 18:54:30 +0200 Subject: [PATCH] feat(diff): allow opening editor from immutable diff views MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - remove is_immutable guard from can_edit_file() so the edit_file keybinding works in Log -> Files -> Diff and other read-only views - move the edit_item command info outside the !is_immutable block - line number is passed via the existing goto logic; no extra change needed - only mutating operations (stage, unstage, reset hunk) remain gated on is_immutable 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude Sonnet 4.6 Co-Authored-By: Claude Code 2.1.143 (Claude Code) Signed-Off-By: Paal Øye-Strømme --- src/components/diff.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/diff.rs b/src/components/diff.rs index 7c5b2376..f02e247a 100644 --- a/src/components/diff.rs +++ b/src/components/diff.rs @@ -153,7 +153,7 @@ impl DiffComponent { } /// const fn can_edit_file(&self) -> bool { - !self.is_immutable && !self.current.path.is_empty() + !self.current.path.is_empty() } /// pub fn clear(&mut self, pending: bool) { @@ -773,12 +773,13 @@ impl Component for DiffComponent { .hidden(), ); + out.push(CommandInfo::new( + strings::commands::edit_item(&self.key_config), + self.can_edit_file(), + self.focused() && self.can_edit_file(), + )); + if !self.is_immutable { - out.push(CommandInfo::new( - strings::commands::edit_item(&self.key_config), - self.can_edit_file(), - self.focused() && self.can_edit_file(), - )); out.push(CommandInfo::new( strings::commands::diff_hunk_remove(&self.key_config), self.selected_hunk.is_some(),