From f55312ba450c845e65f62b5592696d5f6ae98cda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Sat, 24 Feb 2018 19:13:35 +0100 Subject: text-motion: ignore blank lines for next/prev paragraph motions --- text-motions.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/text-motions.c b/text-motions.c index 16137aa..d44e623 100644 --- a/text-motions.c +++ b/text-motions.c @@ -446,19 +446,17 @@ size_t text_paragraph_next(Text *txt, size_t pos) { char c; Iterator it = text_iterator_get(txt, pos); - while (text_iterator_byte_get(&it, &c) && c == '\n') + while (text_iterator_byte_get(&it, &c) && (c == '\n' || blank(c))) text_iterator_char_next(&it, NULL); - return text_line_empty_next(txt, it.pos); + return text_line_blank_next(txt, it.pos); } size_t text_paragraph_prev(Text *txt, size_t pos) { char c; Iterator it = text_iterator_get(txt, pos); - /* c == \0 catches starting the search at EOF */ - while (text_iterator_byte_get(&it, &c) && (c == '\n' || c == '\0')) - text_iterator_byte_prev(&it, NULL); - return text_line_empty_prev(txt, it.pos); + while (text_iterator_byte_prev(&it, &c) && (c == '\n' || blank(c))); + return text_line_blank_prev(txt, it.pos); } size_t text_line_empty_next(Text *txt, size_t pos) { -- cgit v1.2.3