Skip to content

Commit 25c8f3f

Browse files
authored
fix: add line numbers to get_chunk_code results (#3)
1 parent 3e203c6 commit 25c8f3f

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

‎.github/workflows/test.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ jobs:
2020
go-version: '1.24'
2121

2222
- name: Run tests
23-
run: go test ./...
23+
run: go test -v ./...

‎internal/analyzer/analyzer.go‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,14 @@ func (a *Analyzer) getSingleChunkCode(ctx context.Context, id string) string {
160160
return fmt.Sprintf("== %s ==\n\n<source not found for chunk>\n\n", id)
161161
}
162162

163-
return fmt.Sprintf("== %s ==\n\n%s\n\n", id, chunk.Source)
163+
var lineInfo string
164+
if chunk.StartLine == chunk.EndLine {
165+
lineInfo = fmt.Sprintf(" [line %d]", chunk.StartLine)
166+
} else {
167+
lineInfo = fmt.Sprintf(" [lines %d-%d]", chunk.StartLine, chunk.EndLine)
168+
}
169+
170+
return fmt.Sprintf("== %s%s ==\n\n%s\n\n", id, lineInfo, chunk.Source)
164171
}
165172

166173
func (a *Analyzer) GetIndexStatus() (int, time.Time) {

0 commit comments

Comments
 (0)