fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

debug: keep track of debug flag across searches (#484)

Previously it was a hassle to set the debug flag for every search while
debugging. Now we keep track of the state so we only have to set it once.

+8 -4
+3
web/api.go
··· 31 31 32 32 // If set, focus on the search box. 33 33 AutoFocus bool 34 + 35 + // If true, the next search will run in debug mode. 36 + Debug bool 34 37 } 35 38 36 39 // Result holds the data provided to the search results template.
+3 -4
web/server.go
··· 229 229 func (s *Server) serveSearchErr(r *http.Request) (*ApiSearchResult, error) { 230 230 qvals := r.URL.Query() 231 231 232 - debugScore := false 233 - if qvals.Get("debug") == "1" { 234 - debugScore = true 235 - } 232 + debugScore, _ := strconv.ParseBool(qvals.Get("debug")) 236 233 237 234 queryStr := qvals.Get("q") 238 235 if queryStr == "" { ··· 321 318 // Suppress queueing stats if they are neglible. 322 319 res.Stats.Wait = 0 323 320 } 321 + 322 + res.Last.Debug = debugScore 324 323 return &ApiSearchResult{Result: &res}, nil 325 324 } 326 325
+2
web/templates.go
··· 118 118 <input class="form-control" type="number" id="maxhits" name="num" value="{{.Num}}"> 119 119 </div> 120 120 <button class="btn btn-primary">Search</button> 121 + <!--Hack: we use a hidden form field to keep track of the debug flag across searches--> 122 + {{if .Debug}}<input id="debug" name="debug" type="hidden" value="{{.Debug}}">{{end}} 121 123 </div> 122 124 </form> 123 125 </div>