From 3a24e6a5562e4b1ea456fbe36607bd8a9c92744d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 24 Sep 2014 16:16:30 +0200 Subject: Change semantics of text_line_end Also make movement to end of line inclusive. This has the effect that $ moves to the last character on a line but d$ still deletes said character. --- text-motions.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'text-motions.c') diff --git a/text-motions.c b/text-motions.c index 69afcc7..b215ffc 100644 --- a/text-motions.c +++ b/text-motions.c @@ -119,9 +119,7 @@ size_t text_line_start(Text *txt, size_t pos) { size_t text_line_finish(Text *txt, size_t pos) { char c; Iterator it = text_iterator_get(txt, text_line_end(txt, pos)); - do text_iterator_byte_prev(&it, NULL); while (text_iterator_byte_get(&it, &c) && c != '\n' && isspace(c)); - if (!ISUTF8(c)) text_iterator_char_prev(&it, NULL); return it.pos; } @@ -131,6 +129,8 @@ size_t text_line_end(Text *txt, size_t pos) { Iterator it = text_iterator_get(txt, pos); while (text_iterator_byte_get(&it, &c) && c != '\r' && c != '\n') text_iterator_byte_next(&it, NULL); + if (text_iterator_char_prev(&it, &c) && c == '\n') + text_iterator_byte_next(&it, NULL); return it.pos; } -- cgit v1.2.3