diff options
author | 0ko <0ko@noreply.codeberg.org> | 2025-01-01 14:04:22 +0100 |
---|---|---|
committer | 0ko <0ko@noreply.codeberg.org> | 2025-01-01 14:04:22 +0100 |
commit | 13ea8296afdc42f86470c1412ea65729775236df (patch) | |
tree | e6e2790dfcd6d64affbc975f951c3fb5c5d07293 | |
parent | Update dependency @vitest/eslint-plugin to v1.1.22 (forgejo) (#6436) (diff) | |
parent | fix(code search): empty mode dropdown when keyword is empty (diff) | |
download | forgejo-13ea8296afdc42f86470c1412ea65729775236df.tar.xz forgejo-13ea8296afdc42f86470c1412ea65729775236df.zip |
Merge pull request 'fix(code search): empty mode dropdown when keyword is empty' (#6441) from snematoda/no-q-filter-fix into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6441
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
-rw-r--r-- | routers/web/repo/search.go | 9 | ||||
-rw-r--r-- | tests/integration/repo_search_test.go | 1 |
2 files changed, 7 insertions, 3 deletions
diff --git a/routers/web/repo/search.go b/routers/web/repo/search.go index f2264360ec..442034b287 100644 --- a/routers/web/repo/search.go +++ b/routers/web/repo/search.go @@ -67,6 +67,12 @@ func Search(ctx *context.Context) { ctx.Data["CodeSearchPath"] = path ctx.Data["CodeSearchMode"] = mode.String() ctx.Data["PageIsViewCode"] = true + ctx.Data["CodeIndexerDisabled"] = !setting.Indexer.RepoIndexerEnabled + if setting.Indexer.RepoIndexerEnabled { + ctx.Data["CodeSearchOptions"] = code_indexer.CodeSearchOptions + } else { + ctx.Data["CodeSearchOptions"] = git.GrepSearchOptions + } if keyword == "" { ctx.HTML(http.StatusOK, tplSearch) @@ -103,7 +109,6 @@ func Search(ctx *context.Context) { } else { ctx.Data["CodeIndexerUnavailable"] = !code_indexer.IsAvailable(ctx) } - ctx.Data["CodeSearchOptions"] = code_indexer.CodeSearchOptions } else { grepOpt := git.GrepOptions{ ContextLineNumber: 1, @@ -139,10 +144,8 @@ func Search(ctx *context.Context) { strings.Join(r.LineCodes, "\n")), }) } - ctx.Data["CodeSearchOptions"] = git.GrepSearchOptions } - ctx.Data["CodeIndexerDisabled"] = !setting.Indexer.RepoIndexerEnabled ctx.Data["Repo"] = ctx.Repo.Repository ctx.Data["SourcePath"] = ctx.Repo.Repository.Link() ctx.Data["SearchResults"] = searchResults diff --git a/tests/integration/repo_search_test.go b/tests/integration/repo_search_test.go index 259ba36d08..6189dc1150 100644 --- a/tests/integration/repo_search_test.go +++ b/tests/integration/repo_search_test.go @@ -78,6 +78,7 @@ func testSearchRepo(t *testing.T, indexer bool) { code_indexer.UpdateRepoIndexer(repo) } + testSearch(t, "/user2/glob/search?q=", []string{}, indexer) testSearch(t, "/user2/glob/search?q=loren&page=1", []string{"a.txt"}, indexer) testSearch(t, "/user2/glob/search?q=loren&page=1&mode=exact", []string{"a.txt"}, indexer) |