diff options
author | Thomas White <taw@physics.org> | 2017-09-24 15:55:10 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2017-09-24 15:55:10 +0200 |
commit | 36ac3999213068880ae7ff149a3f621fd70389b6 (patch) | |
tree | a5b15ef7989c29447c12386bd9486411d4813f5c /src | |
parent | 4400bbe3a19a96eb646c2e9d1e17bc0e579d871d (diff) |
Jump back into empty paragraphs correctly
Diffstat (limited to 'src')
-rw-r--r-- | src/frame.c | 12 |
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 */ |