瀏覽代碼

use relative line numbers

Johan Rong 1 周之前
父節點
當前提交
939313197d
共有 1 個文件被更改,包括 3 次插入1 次删除
  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]