From eedebd80d47ba5a023cceb6adb46105596314c7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6ran=20Karl?= <3951388+JoeKar@users.noreply.github.com> Date: Mon, 4 Mar 2024 22:22:47 +0100 Subject: [PATCH] util: Fix opening filenames including colons with `parsecursor` (#3119) The regex pattern shall search for the end of the filename first as it does while opening with +LINE:COL. --- internal/util/util.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/util/util.go b/internal/util/util.go index 81448f0d..fb21c487 100644 --- a/internal/util/util.go +++ b/internal/util/util.go @@ -315,7 +315,7 @@ func ReplaceHome(path string) (string, error) { // This is used for opening files like util.go:10:5 to specify a line and column // Special cases like Windows Absolute path (C:\myfile.txt:10:5) are handled correctly. func GetPathAndCursorPosition(path string) (string, []string) { - re := regexp.MustCompile(`([\s\S]+?)(?::(\d+))(?::(\d+))?`) + re := regexp.MustCompile(`([\s\S]+?)(?::(\d+))(?::(\d+))?$`) match := re.FindStringSubmatch(path) // no lines/columns were specified in the path, return just the path with no cursor location if len(match) == 0 {