MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / addLineNumbers

Function addLineNumbers

source code/utils/file.ts:292–321  ·  view source on GitHub ↗
({
  content,
  // 1-indexed
  startLine,
}: {
  content: string
  startLine: number
})

Source from the content-addressed store, hash-verified

290 * Adds cat -n style line numbers to the content.
291 */
292export function addLineNumbers({
293 content,
294 // 1-indexed
295 startLine,
296}: {
297 content: string
298 startLine: number
299}): string {
300 if (!content) {
301 return ''
302 }
303
304 const lines = content.split(/\r?\n/)
305
306 if (isCompactLinePrefixEnabled()) {
307 return lines
308 .map((line, index) => `${index + startLine}\t${line}`)
309 .join('\n')
310 }
311
312 return lines
313 .map((line, index) => {
314 const numStr = String(index + startLine)
315 if (numStr.length >= 6) {
316 return `${numStr}→${line}`
317 }
318 return `${numStr.padStart(6, ' ')}→${line}`
319 })
320 .join('\n')
321}
322
323/**
324 * Inverse of addLineNumbers — strips the `N→` or `N\t` prefix from a single

Callers 2

formatFileLinesFunction · 0.85
getSnippetForPatchFunction · 0.85

Calls 1

Tested by

no test coverage detected