fix formatting

This commit is contained in:
aaronknudtson 2024-06-27 23:07:00 -04:00
parent ed8d76be3b
commit a3a47886c8
9 changed files with 13 additions and 18 deletions

View File

@ -26,7 +26,7 @@ type SearchOptions struct {
Language string
IsKeywordFuzzy bool
IsHtmlSafe bool
IsHTMLSafe bool
db.Paginator
}

View File

@ -102,7 +102,7 @@ func RawSearchResultCode(filename, language string, lineNums []int, code string)
return lines
}
func searchResult(result *internal.SearchResult, startIndex, endIndex int, escapeHtml bool) (*Result, error) {
func searchResult(result *internal.SearchResult, startIndex, endIndex int, escapeHTML bool) (*Result, error) {
startLineNum := 1 + strings.Count(result.Content[:startIndex], "\n")
var formattedLinesBuffer bytes.Buffer
@ -134,7 +134,7 @@ func searchResult(result *internal.SearchResult, startIndex, endIndex int, escap
}
var lines []*ResultLine
if escapeHtml {
if escapeHTML {
lines = HighlightSearchResultCode(result.Filename, result.Language, lineNums, formattedLinesBuffer.String())
} else {
lines = RawSearchResultCode(result.Filename, result.Language, lineNums, formattedLinesBuffer.String())
@ -166,13 +166,13 @@ func PerformSearch(ctx context.Context, opts *SearchOptions) (int, []*Result, []
displayResults := make([]*Result, len(results))
nLinesBuffer := 0
if opts.IsHtmlSafe {
if opts.IsHTMLSafe {
nLinesBuffer = 1
}
for i, result := range results {
startIndex, endIndex := indices(result.Content, result.StartIndex, result.EndIndex, nLinesBuffer)
displayResults[i], err = searchResult(result, startIndex, endIndex, opts.IsHtmlSafe)
displayResults[i], err = searchResult(result, startIndex, endIndex, opts.IsHTMLSafe)
if err != nil {
return 0, nil, nil, err
}

View File

@ -85,6 +85,7 @@ import (
"code.gitea.io/gitea/modules/web"
"code.gitea.io/gitea/routers/api/v1/activitypub"
"code.gitea.io/gitea/routers/api/v1/admin"
"code.gitea.io/gitea/routers/api/v1/explore"
"code.gitea.io/gitea/routers/api/v1/misc"
"code.gitea.io/gitea/routers/api/v1/notify"
"code.gitea.io/gitea/routers/api/v1/org"
@ -92,7 +93,6 @@ import (
"code.gitea.io/gitea/routers/api/v1/repo"
"code.gitea.io/gitea/routers/api/v1/settings"
"code.gitea.io/gitea/routers/api/v1/user"
"code.gitea.io/gitea/routers/api/v1/explore"
"code.gitea.io/gitea/routers/common"
"code.gitea.io/gitea/services/actions"
"code.gitea.io/gitea/services/auth"

View File

@ -94,7 +94,7 @@ func Code(ctx *context.APIContext) {
RepoIDs: repoIDs,
Keyword: keyword,
IsKeywordFuzzy: isFuzzy,
IsHtmlSafe: false,
IsHTMLSafe: false,
Paginator: &db.ListOptions{
Page: page,
PageSize: setting.API.DefaultPagingNum,

View File

@ -10,6 +10,6 @@ import (
// ExploreCode
// swagger:response ExploreCode
type swaggerResponseExploreCode struct {
// out:body
Body api.ExploreCodeResult `json:"body"`
// in:body
Body api.ExploreCodeResult `json:"body"`
}

View File

@ -81,7 +81,7 @@ func Code(ctx *context.Context) {
RepoIDs: repoIDs,
Keyword: keyword,
IsKeywordFuzzy: isFuzzy,
IsHtmlSafe: true,
IsHTMLSafe: true,
Language: language,
Paginator: &db.ListOptions{
Page: page,

View File

@ -59,7 +59,7 @@ func Search(ctx *context.Context) {
RepoIDs: []int64{ctx.Repo.Repository.ID},
Keyword: keyword,
IsKeywordFuzzy: isFuzzy,
IsHtmlSafe: true,
IsHTMLSafe: true,
Language: language,
Paginator: &db.ListOptions{
Page: page,

View File

@ -80,7 +80,7 @@ func CodeSearch(ctx *context.Context) {
Keyword: keyword,
IsKeywordFuzzy: isFuzzy,
Language: language,
IsHtmlSafe: true,
IsHTMLSafe: true,
Paginator: &db.ListOptions{
Page: page,
PageSize: setting.UI.RepoSearchPagingNum,

View File

@ -25484,11 +25484,6 @@
"description": "ExploreCode",
"schema": {
"$ref": "#/definitions/ExploreCodeResult"
},
"headers": {
"body": {
"description": "out:body"
}
}
},
"FileDeleteResponse": {
@ -26337,4 +26332,4 @@
"TOTPHeader": []
}
]
}
}