Browse Source

use relative line numbers

Johan Rong 1 week ago
parent
commit
939313197d
1 changed files with 3 additions and 1 deletions
  1. 3 1
      internal/editor/draw.go

+ 3 - 1
internal/editor/draw.go

@@ -220,7 +220,9 @@ func (m *Model) DrawBuffer(buf *buffer.Buffer, isActive bool, rect layout.Rect)
 	for j, line := range table {
 		if j + 1 > rect.Height { break }
 
-		nums := fmt.Sprintf("%4d ", j + buf.TopLine)
+		lineNum := j + buf.TopLine
+		relLine := lineNum - curLine
+		nums := fmt.Sprintf("%4d ", relLine)
 		r := []rune(nums + expandTabs(line))
 		if len(r) + 1 > rect.Width {
 			r = r[:rect.Width]