aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2017-09-24 15:55:10 +0200
committerThomas White <taw@physics.org>2017-09-24 15:55:10 +0200
commit36ac3999213068880ae7ff149a3f621fd70389b6 (patch)
treea5b15ef7989c29447c12386bd9486411d4813f5c
parent4400bbe3a19a96eb646c2e9d1e17bc0e579d871d (diff)
Jump back into empty paragraphs correctly
-rw-r--r--src/frame.c12
1 files 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 */