From d08ab91c1936613e95daad3c56e24125f7899166 Mon Sep 17 00:00:00 2001 From: po3rin Date: Sun, 28 Jul 2024 00:18:25 +0900 Subject: [PATCH 1/2] Enabling numContextLines in non-json format --- web/server.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/web/server.go b/web/server.go index 75b631fd2..0c717e89a 100644 --- a/web/server.go +++ b/web/server.go @@ -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 From f6c0e0ed13efc442ed64ae94fab8939770835f8b Mon Sep 17 00:00:00 2001 From: po3rin Date: Sun, 28 Jul 2024 14:11:26 +0900 Subject: [PATCH 2/2] add ctx in LastInput --- web/api.go | 1 + web/server.go | 1 + 2 files changed, 2 insertions(+) diff --git a/web/api.go b/web/api.go index 8d07ae307..4f8c1468c 100644 --- a/web/api.go +++ b/web/api.go @@ -28,6 +28,7 @@ type ApiSearchResult struct { type LastInput struct { Query string Num int + Ctx int // If set, focus on the search box. AutoFocus bool diff --git a/web/server.go b/web/server.go index 0c717e89a..89c9fed27 100644 --- a/web/server.go +++ b/web/server.go @@ -311,6 +311,7 @@ func (s *Server) serveSearchErr(r *http.Request) (*ApiSearchResult, error) { Last: LastInput{ Query: queryStr, Num: num, + Ctx: numCtxLines, AutoFocus: true, }, Stats: result.Stats,