Skip to content

Commit 818ca17

Browse files
authored
Fix matching of lazygit-edit URLs without line numbers (#5311)
### PR Description 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. Fixes #5308
2 parents f8676ff + 8821770 commit 818ca17

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pkg/gui/gui.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ func (gui *Gui) onNewRepo(startArgs appTypes.StartArgs, contextKey types.Context
377377

378378
gui.g.SetOpenHyperlinkFunc(func(url string, viewname string) error {
379379
if strings.HasPrefix(url, "lazygit-edit:") {
380-
re := regexp.MustCompile(`^lazygit-edit://(.+?)(?::(\d+))?$`)
380+
re := regexp.MustCompile(`^lazygit-edit://(.+?)(?::(\d*))?$`)
381381
matches := re.FindStringSubmatch(url)
382382
if matches == nil {
383383
return fmt.Errorf(gui.Tr.InvalidLazygitEditURL, url)

0 commit comments

Comments
 (0)