Skip to content

Commit

Permalink
Fix index out of range when calculating tag intersection
Browse files Browse the repository at this point in the history
Shouldn't rely on "matched tags" returning any results, if the tag
fails to find anything we shouldn't continue to find the intersection
of the non-existant tags.
  • Loading branch information
msp301 committed Oct 27, 2023
1 parent d5b1e97 commit a34b4ab
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions notebook/notebook.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@ func (book *Notebook) MatchedTags(searchTags ...string) []matchedTag {

func (book *Notebook) TagIntersection(matchedTags []matchedTag) []graph.Vertex {
var intersection = make(map[uint64]graph.Vertex)

if len(matchedTags) == 0 {
return nil
}

var mostConnectedVertex = matchedTags[0]
VERTEX:
for vertexId := range book.Notes.Adjacency[mostConnectedVertex.Vertex.Id] {
Expand Down

0 comments on commit a34b4ab

Please sign in to comment.