From 5b0091f65054a75fe6a88ec9ebb6817ac0f09736 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Thu, 11 Jun 2026 15:44:20 +0200 Subject: [PATCH] Extract editDiffLine from editLine The `e` keybinding resolves the file/line of the selected diff line and opens it in the editor. A forthcoming right-click handler needs the same resolve-and-edit step for the clicked line rather than the selected one, so split it out behind a view-line-index argument. No behavior change. Co-Authored-By: Claude Opus 4.8 (1M context) --- pkg/gui/controllers/main_view_controller.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/gui/controllers/main_view_controller.go b/pkg/gui/controllers/main_view_controller.go index 068318106..75fb9e625 100644 --- a/pkg/gui/controllers/main_view_controller.go +++ b/pkg/gui/controllers/main_view_controller.go @@ -291,9 +291,13 @@ func (self *MainViewController) editLine() error { if !self.context.GetView().Highlight { return nil } - // Figure out the clicked file and line the same way entering staging does. - info, ok := self.c.Helpers().Staging.GetDiffLineInfo( - self.context.GetViewName(), self.context.GetView().SelectedLineIdx()) + return self.editDiffLine(self.context.GetView().SelectedLineIdx()) +} + +// editDiffLine opens the file the given diff line belongs to in the editor, at +// that line. The file and line are resolved the same way entering staging does. +func (self *MainViewController) editDiffLine(viewLineIdx int) error { + info, ok := self.c.Helpers().Staging.GetDiffLineInfo(self.context.GetViewName(), viewLineIdx) if !ok { return nil }