1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2025-08-01 17:38:33 +00:00

ui(git-grep): expose regexp mode in dropdown

This commit is contained in:
Shiny Nematoda 2024-08-16 13:23:25 +00:00 committed by Radosław Piliszek
parent 6d6116857c
commit 663e957d3d
8 changed files with 66 additions and 20 deletions

View file

@ -27,7 +27,7 @@ const (
func searchModeFromString(s string) searchMode {
switch s {
case "fuzzy":
case "fuzzy", "union":
return FuzzySearchMode
case "regexp":
return RegExpSearchMode
@ -65,7 +65,7 @@ func Search(ctx *context.Context) {
ctx.Data["Language"] = language
ctx.Data["IsFuzzy"] = mode == FuzzySearchMode
ctx.Data["IsRegExp"] = mode == RegExpSearchMode
ctx.Data["SearchMode"] = mode.String()
ctx.Data["CodeSearchMode"] = mode.String()
ctx.Data["PageIsViewCode"] = true
if keyword == "" {
@ -102,6 +102,7 @@ func Search(ctx *context.Context) {
} else {
ctx.Data["CodeIndexerUnavailable"] = !code_indexer.IsAvailable(ctx)
}
ctx.Data["CodeSearchOptions"] = []string{"exact", "fuzzy"}
} else {
grepOpt := git.GrepOptions{
ContextLineNumber: 1,
@ -110,6 +111,7 @@ func Search(ctx *context.Context) {
switch mode {
case FuzzySearchMode:
grepOpt.Mode = git.FixedAnyGrepMode
ctx.Data["CodeSearchMode"] = "union"
case RegExpSearchMode:
grepOpt.Mode = git.RegExpGrepMode
}
@ -133,6 +135,7 @@ func Search(ctx *context.Context) {
Lines: code_indexer.HighlightSearchResultCode(r.Filename, r.LineNumbers, r.HighlightedRanges, strings.Join(r.LineCodes, "\n")),
})
}
ctx.Data["CodeSearchOptions"] = []string{"exact", "union", "regexp"}
}
ctx.Data["CodeIndexerDisabled"] = !setting.Indexer.RepoIndexerEnabled