~delthas/senpai

6ed6f0bfd4c9784ef4d8ac1b15f7bcecdd3f9ce2 — delthas 2 months ago d852436
Keep cursor position on reducing the terminal width

Fixes: https://todo.sr.ht/~delthas/senpai/138
1 files changed, 2 insertions(+), 4 deletions(-)

M ui/editor.go
M ui/editor.go => ui/editor.go +2 -4
@@ 85,10 85,8 @@ func NewEditor(ui *UI) Editor {

func (e *Editor) Resize(width int) {
	if width < e.width {
		e.cursorIdx = 0
		e.offsetIdx = 0
		e.autoCache = nil
		e.backsearchEnd()
		// Reset cursor to the same size, to recompute offsetIdx
		e.setCursor(e.textWidth[e.cursorIdx])
	}
	e.width = width
}