Skip to content

Commit

Permalink
util: Fix opening filenames including colons with parsecursor (#3119)
Browse files Browse the repository at this point in the history
The regex pattern shall search for the end of the filename first as it does
while opening with +LINE:COL.
  • Loading branch information
JoeKar authored Mar 4, 2024
1 parent e5026ef commit eedebd8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion internal/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit eedebd8

Please sign in to comment.