MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / parseRipgrepLine

Function parseRipgrepLine

common/src/util/format-code-search.ts:79–108  ·  view source on GitHub ↗
(line: string)

Source from the content-addressed store, hash-verified

77}
78
79function parseRipgrepLine(line: string): {
80 filePath: string
81 lineNumber: string
82 content: string
83 isContext: boolean
84} | null {
85 // Try match line pattern: filename:digits:content
86 const matchLineMatch = line.match(/(.*?):(\d+):(.*)$/)
87 if (matchLineMatch) {
88 return {
89 filePath: matchLineMatch[1],
90 lineNumber: matchLineMatch[2],
91 content: matchLineMatch[3],
92 isContext: false,
93 }
94 }
95
96 // Try context line pattern: filename-digits-content
97 const contextLineMatch = line.match(/(.*?)-(\d+)-(.*)$/)
98 if (contextLineMatch) {
99 return {
100 filePath: contextLineMatch[1],
101 lineNumber: contextLineMatch[2],
102 content: contextLineMatch[3],
103 isContext: true,
104 }
105 }
106
107 return null
108}
109
110function countFormattedMatches(lines: string[]): number {
111 return lines.filter((line) => {

Callers 2

formatCodeSearchOutputFunction · 0.85
countFormattedMatchesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected