diff --git a/app/api/controller/keywordsearch/search.go b/app/api/controller/keywordsearch/search.go index 64a62ce41..23c206033 100644 --- a/app/api/controller/keywordsearch/search.go +++ b/app/api/controller/keywordsearch/search.go @@ -44,11 +44,13 @@ func (c *Controller) Search( return types.SearchResult{}, fmt.Errorf("failed to search repos by path: %w", err) } - if len(repoIDToPathMap) == 0 { - repoIDToPathMap, err = c.getReposBySpacePaths(ctx, session, in.SpacePaths) - if err != nil { - return types.SearchResult{}, fmt.Errorf("failed to search repos by space path: %w", err) - } + spaceRepoIDToPathMap, err := c.getReposBySpacePaths(ctx, session, in.SpacePaths) + if err != nil { + return types.SearchResult{}, fmt.Errorf("failed to search repos by space path: %w", err) + } + + for repoID, repoPath := range spaceRepoIDToPathMap { + repoIDToPathMap[repoID] = repoPath } if len(repoIDToPathMap) == 0 { diff --git a/types/search.go b/types/search.go index bbc33f853..e81c00515 100644 --- a/types/search.go +++ b/types/search.go @@ -19,7 +19,6 @@ type ( Query string `json:"query"` // RepoPaths contains the paths of repositories to search in - // If both space path and repo path are provided, the repo path will be used RepoPaths []string `json:"repo_paths"` // SpacePaths contains the paths of spaces to search in