MCPcopy Create free account
hub / github.com/coder/coder / formatMiscount

Function formatMiscount

agent/agentfiles/files.go:1363–1377  ·  view source on GitHub ↗

formatMiscount renders one miscount candidate group.

(sCount int, r rune, cands []candidate)

Source from the content-addressed store, hash-verified

1361
1362// formatMiscount renders one miscount candidate group.
1363func formatMiscount(sCount int, r rune, cands []candidate) string {
1364 var b strings.Builder
1365 _, _ = fmt.Fprintf(&b, "Your search has %d %q (U+%04X); the file has ", sCount, string(r), r)
1366 shown := min(len(cands), maxHintLines)
1367 for i := 0; i < shown; i++ {
1368 if i > 0 {
1369 _, _ = b.WriteString(", ")
1370 }
1371 _, _ = fmt.Fprintf(&b, "%d at line %d", cands[i].cCount, cands[i].line)
1372 }
1373 if rest := len(cands) - shown; rest > 0 {
1374 _, _ = fmt.Fprintf(&b, " and %d more", rest)
1375 }
1376 return b.String()
1377}
1378
1379// candidate records a file line where one rune's count disagrees with
1380// the search.

Callers 1

miscountHintFunction · 0.85

Calls 2

WriteStringMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected