MCPcopy Create free account
hub / github.com/driangle/taskmd / countLines

Function countLines

apps/cli/internal/taskcontext/resolve.go:304–314  ·  view source on GitHub ↗

countLines returns the number of lines in content, handling trailing newlines correctly.

(content string)

Source from the content-addressed store, hash-verified

302
303// countLines returns the number of lines in content, handling trailing newlines correctly.
304func countLines(content string) int {
305 if content == "" {
306 return 0
307 }
308 n := strings.Count(content, "\n")
309 // If file ends with newline, the last "line" is empty — don't count it
310 if strings.HasSuffix(content, "\n") {
311 return n
312 }
313 return n + 1
314}
315
316// capFiles truncates the file list to maxFiles entries.
317func capFiles(files []FileEntry, maxFiles int) []FileEntry {

Callers 1

inlineContentsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected