MCPcopy Index your code
hub / github.com/coder/coder / formatLineList

Function formatLineList

agent/agentfiles/files.go:1302–1315  ·  view source on GitHub ↗

formatLineList renders a sorted line list as "12, 47, 89", truncated to maxHintLines entries with " and N more" when more exist.

(lines []int)

Source from the content-addressed store, hash-verified

1300// formatLineList renders a sorted line list as "12, 47, 89", truncated
1301// to maxHintLines entries with " and N more" when more exist.
1302func formatLineList(lines []int) string {
1303 var b strings.Builder
1304 shown := min(len(lines), maxHintLines)
1305 for i := 0; i < shown; i++ {
1306 if i > 0 {
1307 _, _ = b.WriteString(", ")
1308 }
1309 _, _ = fmt.Fprintf(&b, "%d", lines[i])
1310 }
1311 if rest := len(lines) - shown; rest > 0 {
1312 _, _ = fmt.Fprintf(&b, " and %d more", rest)
1313 }
1314 return b.String()
1315}
1316
1317// miscountHint detects search lines that match a file line except for
1318// the count of one repeated rune. Emits one hint per

Callers 1

inversionHintFunction · 0.85

Calls 2

WriteStringMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected