Skip to content

Commit

Permalink
fix: gutter index
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Feb 10, 2025
1 parent de95b7d commit 8be3df0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion viewport/viewport.go
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,15 @@ func (m Model) prependColumn(lines []string) []string {
if m.LeftGutterFunc == nil {
return lines
}

offset := max(0, m.lineToIndex(m.YOffset))
total := m.TotalLineCount()
result := make([]string, len(lines))
for i := range lines {
var line []string
for j, realLine := range strings.Split(lines[i], "\n") {
line = append(line, m.LeftGutterFunc(GutterContext{
Index: i + m.YOffset,
Index: i + offset,
TotalLines: total,
Soft: j > 0,
})+realLine)
Expand Down

0 comments on commit 8be3df0

Please sign in to comment.