Skip to content

Commit

Permalink
concurrent/map: Nil map is empty
Browse files Browse the repository at this point in the history
Signed-off-by: Charlie Egan <[email protected]>
  • Loading branch information
charlieegan3 committed Jan 9, 2025
1 parent de996a2 commit a47ab6d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion internal/lsp/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,7 @@ func (l *LanguageServer) determineVersionForFile(fileURI string) ast.RegoVersion
var versionedDirs []string

// if we have no information, then we can return the default
if l.loadedConfigAllRegoVersions == nil || l.loadedConfigAllRegoVersions.Len() == 0 {
if l.loadedConfigAllRegoVersions.Len() == 0 {
return ast.RegoV1
}

Expand Down
4 changes: 4 additions & 0 deletions internal/util/concurrent/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ func (cm *Map[K, V]) Values() []V {
}

func (cm *Map[K, V]) Len() int {
if cm == nil {
return 0
}

cm.murw.RLock()

l := len(cm.m)
Expand Down

0 comments on commit a47ab6d

Please sign in to comment.