commit 6ed6f0b

delthas  ·  2024-07-03 12:36:26 +0000 UTC
parent d852436
Keep cursor position on reducing the terminal width

Fixes: https://todo.sr.ht/~delthas/senpai/138
1 files changed,  +2, -4
+2, -4
 1@@ -85,10 +85,8 @@ func NewEditor(ui *UI) Editor {
 2 
 3 func (e *Editor) Resize(width int) {
 4 	if width < e.width {
 5-		e.cursorIdx = 0
 6-		e.offsetIdx = 0
 7-		e.autoCache = nil
 8-		e.backsearchEnd()
 9+		// Reset cursor to the same size, to recompute offsetIdx
10+		e.setCursor(e.textWidth[e.cursorIdx])
11 	}
12 	e.width = width
13 }