Diff debugging

This commit is contained in:
Matt Rubens
2024-12-16 10:24:08 -05:00
parent 5fcf6f0821
commit c2b4b05459
15 changed files with 157 additions and 63 deletions

View File

@@ -53,15 +53,12 @@ async function extractTextFromIPYNB(filePath: string): Promise<string> {
return addLineNumbers(extractedText)
}
export function addLineNumbers(content: string): string {
export function addLineNumbers(content: string, startLine: number = 1): string {
const lines = content.split('\n')
const maxLineNumberWidth = String(lines.length).length
const maxLineNumberWidth = String(startLine + lines.length - 1).length
return lines
.map((line, index) => {
const lineNumber = String(index + 1).padStart(maxLineNumberWidth, ' ')
const lineNumber = String(startLine + index).padStart(maxLineNumberWidth, ' ')
return `${lineNumber} | ${line}`
}).join('\n')
}
}