Skip to content

Commit

Permalink
Enabling numContextLines in non-json format
Browse files Browse the repository at this point in the history
  • Loading branch information
Hiromu Nakamura committed Jul 27, 2024
1 parent 12ce07a commit e760c7b
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions web/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,12 +280,10 @@ func (s *Server) serveSearchErr(r *http.Request) (*ApiSearchResult, error) {
}

numCtxLines := 0
if qvals.Get("format") == "json" {
if ctxLinesStr := qvals.Get("ctx"); ctxLinesStr != "" {
numCtxLines, err = strconv.Atoi(ctxLinesStr)
if err != nil || numCtxLines < 0 || numCtxLines > 10 {
return nil, fmt.Errorf("Number of context lines must be between 0 and 10")
}
if ctxLinesStr := qvals.Get("ctx"); ctxLinesStr != "" {
numCtxLines, err = strconv.Atoi(ctxLinesStr)
if err != nil || numCtxLines < 0 || numCtxLines > 10 {
return nil, fmt.Errorf("Number of context lines must be between 0 and 10")
}
}
sOpts.NumContextLines = numCtxLines
Expand Down

0 comments on commit e760c7b

Please sign in to comment.