From 1cb6619d6acdf72a634686b6e39cabfa9b9c3361 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg <bensberg@justemail.net> Date: Mon, 19 Dec 2016 21:18:43 +0100 Subject: [PATCH] undo: there are just two forms of deletion: backspacing and deleting A third method does not exist. --- src/text.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/text.c b/src/text.c index 6465a927..69b99b37 100644 --- a/src/text.c +++ b/src/text.c @@ -1366,21 +1366,15 @@ fprintf(stderr, " >> Updating... action = %d, openfile->last_action = %d, openf } case BACK: case DEL: { + /* Add the removed character after or before earlier removed stuff. */ char *char_buf = charalloc(mb_cur_max()); int char_len = parse_mbchar(&openfile->current->data[openfile->current_x], char_buf, NULL); - if (openfile->current_x == u->begin) { - /* They're deleting. */ + if (action == DEL) { u->strdata = addstrings(u->strdata, strlen(u->strdata), char_buf, char_len); u->mark_begin_x = openfile->current_x; - } else if (openfile->current_x == u->begin - char_len) { - /* They're backspacing. */ + } else { u->strdata = addstrings(char_buf, char_len, u->strdata, strlen(u->strdata)); u->begin = openfile->current_x; - } else { - /* They deleted something else on the line. */ - free(char_buf); - add_undo(u->type); - return; } #ifdef DEBUG fprintf(stderr, " >> current undo data is \"%s\"\nu->begin = %lu\n", u->strdata, (unsigned long)u->begin); -- GitLab