Skip to content

Commit

Permalink
fix: magnet link (#429)
Browse files Browse the repository at this point in the history
lsp to ignore magnet links as links to notes.

Co-authored-by: Tillman Jex <tjex@tjex.net>
  • Loading branch information
billymosis and tjex authored Jul 11, 2024
1 parent 739d2d4 commit 53df879
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/adapter/lsp/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ var fileURIregex = regexp.MustCompile(`file:///`)
var fencedStartRegex = regexp.MustCompile(`^(` + "```" + `|~~~).*`)
var fencedEndRegex = regexp.MustCompile(`^(` + "```" + `|~~~)\s*`)
var indentedRegex = regexp.MustCompile(`^(\s{4}|\t).+`)
var magnetRegex = regexp.MustCompile(`magnet:\?`)

var insideInline = false
var insideFenced = false
Expand Down Expand Up @@ -303,11 +304,11 @@ func (d *document) DocumentLinks() ([]documentLink, error) {
continue
}

// ignore tripple dash file URIs [title](file:///foo.go)
// ignore tripple dash file URIs [title](file:///foo.go) and magnet links
if match[5]-match[4] >= 8 {
linkURL := line[match[4]:match[5]]
fileURIresult := linkURL[:8]
if fileURIregex.MatchString(fileURIresult) {
if fileURIregex.MatchString(fileURIresult) || magnetRegex.MatchString(fileURIresult) {
continue
}
}
Expand Down

0 comments on commit 53df879

Please sign in to comment.