From 36ac3999213068880ae7ff149a3f621fd70389b6 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sun, 24 Sep 2017 15:55:10 +0200 Subject: Jump back into empty paragraphs correctly --- src/frame.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/frame.c b/src/frame.c index b224d1c..1dc9f4f 100644 --- a/src/frame.c +++ b/src/frame.c @@ -765,9 +765,17 @@ void cursor_moveh(struct frame *fr, int *cpara, size_t *cpos, int *ctrail, dir, &np, ctrail); if ( np == -1 ) { if ( *cpara > 0 ) { + size_t end_offs; (*cpara)--; - *cpos = end_offset_of_para(fr, *cpara) - 1; - *ctrail = 1; + end_offs = end_offset_of_para(fr, *cpara); + if ( end_offs > 0 ) { + *cpos = end_offs - 1; + *ctrail = 1; + } else { + /* Jumping into an empty paragraph */ + *cpos = 0; + *ctrail = 0; + } return; } else { /* Can't move any further */ -- cgit v1.2.3