From 8821770711f769ee8b6bccb4f563bf5d5969fc8e Mon Sep 17 00:00:00 2001 From: Daniel Wennberg Date: Thu, 19 Feb 2026 15:57:49 -0800 Subject: [PATCH] Fix matching of lazygit-edit URLs without line numbers Tweak regexp such that a trailing ":" is not included in the file path extracted from a lazygit-edit URL. Previously, when matching a URL containing the ":" separator but no line number, such as `lazygit-edit:///path/to/file.ext:`, the trailing separator would be included in the matched file path, so lazygit would open the non-existent file `/path/to/file.ext:`. Notably, such urls are created when using delta with the hyperlink feature, as suggested in https://github.com/jesseduffield/lazygit/blob/master/docs/Custom_Pagers.md#delta, and clicking a file path rather than a line number. --- pkg/gui/gui.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go index a7e17ef9f..f3b752cee 100644 --- a/pkg/gui/gui.go +++ b/pkg/gui/gui.go @@ -377,7 +377,7 @@ func (gui *Gui) onNewRepo(startArgs appTypes.StartArgs, contextKey types.Context gui.g.SetOpenHyperlinkFunc(func(url string, viewname string) error { if strings.HasPrefix(url, "lazygit-edit:") { - re := regexp.MustCompile(`^lazygit-edit://(.+?)(?::(\d+))?$`) + re := regexp.MustCompile(`^lazygit-edit://(.+?)(?::(\d*))?$`) matches := re.FindStringSubmatch(url) if matches == nil { return fmt.Errorf(gui.Tr.InvalidLazygitEditURL, url)