tweaks: copy and store a deleted character in a conciser manner
parent
e6f26464d7
commit
c055e629c7
|
@ -1145,11 +1145,10 @@ void add_undo(undo_type action, const char *message)
|
||||||
/* When not at the end of a line, store the deleted character;
|
/* When not at the end of a line, store the deleted character;
|
||||||
* otherwise, morph the undo item into a line join. */
|
* otherwise, morph the undo item into a line join. */
|
||||||
if (openfile->current->data[openfile->current_x] != '\0') {
|
if (openfile->current->data[openfile->current_x] != '\0') {
|
||||||
char *char_buf = charalloc(MAXCHARLEN + 1);
|
int charlen = char_length(openfile->current->data + u->head_x);
|
||||||
int charlen = collect_char(&openfile->current->data[u->head_x],
|
|
||||||
char_buf);
|
u->strdata = measured_copy(openfile->current->data + u->head_x,
|
||||||
char_buf[charlen] = '\0';
|
charlen);
|
||||||
u->strdata = char_buf;
|
|
||||||
if (u->type == BACK)
|
if (u->type == BACK)
|
||||||
u->tail_x += charlen;
|
u->tail_x += charlen;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue