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) <noreply@anthropic.com>
This commit is contained in:
Stefan Haller 2026-06-11 15:44:20 +02:00
parent aa4ff00898
commit 5b0091f650

View file

@ -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
}