vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 48dd9f143c08799b28000ad8b381d245928d7a83 parent 27b6636421c3216741a56d95c28395a49de25fc2 Author: Marc André Tanner <mat@brain-dump.org> Date: Thu, 25 Sep 2014 11:31:38 +0200 Revert "Change semantics of text_line_end" This reverts commit c6a8f52e2532afb257322efdfb5d5746a89d460f. Diffstat:
| M | text-motions.c | | | 4 | ++-- |
| M | text-motions.h | | | 4 | ++-- |
| M | vis.c | | | 6 | +++--- |
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/text-motions.c b/text-motions.c @@ -119,7 +119,9 @@ 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; } @@ -129,8 +131,6 @@ 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; } diff --git a/text-motions.h b/text-motions.h @@ -24,8 +24,8 @@ size_t text_find_char_prev(Text*, size_t pos, const char *s, size_t len); /* begin finish next * v v v * [\r]\n I am a line! [\r]\n - * ^ ^ ^ - * prev start end + * ^ ^ ^ + * prev start end */ size_t text_line_prev(Text*, size_t pos); size_t text_line_begin(Text*, size_t pos); diff --git a/vis.c b/vis.c @@ -263,7 +263,7 @@ static Movement moves[] = { [MOVE_LINE_BEGIN] = { .txt = text_line_begin, .type = LINEWISE }, [MOVE_LINE_START] = { .txt = text_line_start, .type = LINEWISE }, [MOVE_LINE_FINISH] = { .txt = text_line_finish, .type = LINEWISE }, - [MOVE_LINE_END] = { .txt = text_line_end, .type = LINEWISE|INCLUSIVE }, + [MOVE_LINE_END] = { .txt = text_line_end, .type = LINEWISE }, [MOVE_LINE_NEXT] = { .txt = text_line_next, .type = LINEWISE }, [MOVE_LINE] = { .cmd = line, .type = LINEWISE|IDEMPOTENT}, [MOVE_COLUMN] = { .cmd = column, .type = CHARWISE|IDEMPOTENT}, @@ -936,7 +936,7 @@ static void joinline(const Arg *arg) { Text *txt = vis->win->text; size_t pos = window_cursor_get(vis->win->win), start, end; if (arg->i == MOVE_LINE_NEXT) { - start = text_line_prev(txt, text_line_next(txt, pos)); + start = text_line_end(txt, pos); end = text_line_next(txt, pos); } else { end = text_line_begin(txt, pos); @@ -997,7 +997,7 @@ static void action_do(Action *a) { Filerange sel = window_selection_get(win); sel.end = text_char_prev(txt, sel.end); size_t start = text_line_begin(txt, sel.start); - size_t end = text_line_prev(txt, text_line_next(txt, sel.end)); + size_t end = text_line_end(txt, sel.end); if (sel.start == pos) { /* extend selection upwards */ sel.end = start; sel.start = end;