aboutsummaryrefslogtreecommitdiff
path: root/text-motions.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2014-09-24 16:16:30 +0200
committerMarc André Tanner <mat@brain-dump.org>2014-09-24 16:16:30 +0200
commit3a24e6a5562e4b1ea456fbe36607bd8a9c92744d (patch)
treebef2a4f40fbacc6074eab0dc682ff8c3345b3ff7 /text-motions.c
parent6703eb20d1fd5c05545f8f1360eef3020bb9d8b8 (diff)
downloadvis-3a24e6a5562e4b1ea456fbe36607bd8a9c92744d.tar.gz
vis-3a24e6a5562e4b1ea456fbe36607bd8a9c92744d.tar.xz
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.
Diffstat (limited to 'text-motions.c')
-rw-r--r--text-motions.c4
1 files changed, 2 insertions, 2 deletions
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;
}