1
1

undo: when adding text adds a magicline, an undo should remove both

This fixes http://savannah.gnu.org/bugs/?52523.
Этот коммит содержится в:
David Lawrence Ramsey 2017-11-27 11:11:30 -06:00 коммит произвёл Benno Schulenberg
родитель d646a3b97b
Коммит b9638cb7cc
3 изменённых файлов: 17 добавлений и 9 удалений

Просмотреть файл

@ -1813,13 +1813,6 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
if (!allow_cntrls && is_ascii_cntrl_char(*(output + i - char_len)))
continue;
/* If we're adding to the magicline, create a new magicline. */
if (!ISSET(NO_NEWLINES) && openfile->filebot == openfile->current) {
new_magicline();
if (margin > 0)
refresh_needed = TRUE;
}
/* Make room for the new character and copy it into the line. */
openfile->current->data = charealloc(openfile->current->data,
current_len + char_len + 1);
@ -1856,6 +1849,13 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
update_undo(ADD);
#endif
/* If we've added text to the magicline, create a new magicline. */
if (openfile->filebot == openfile->current && !ISSET(NO_NEWLINES)) {
new_magicline();
if (margin > 0)
refresh_needed = TRUE;
}
#ifdef ENABLE_WRAPPING
/* If text gets wrapped, the edit window needs a refresh. */
if (!ISSET(NO_WRAP) && do_wrap(openfile->current))

Просмотреть файл

@ -607,9 +607,10 @@ enum
/* Some extra flags for the undo function. */
#define WAS_FINAL_BACKSPACE (1<<1)
#define WAS_WHOLE_LINE (1<<2)
#define WAS_FINAL_LINE (1<<3)
/* The flags for the mark need to be the highest. */
#define MARK_WAS_SET (1<<3)
#define WAS_MARKED_FORWARD (1<<4)
#define MARK_WAS_SET (1<<4)
#define WAS_MARKED_FORWARD (1<<5)
#endif /* !NANO_TINY */
/* The maximum number of entries displayed in the main shortcut list. */

Просмотреть файл

@ -734,6 +734,8 @@ void do_undo(void)
/* TRANSLATORS: The next twelve strings describe actions
* that are undone or redone. It are all nouns, not verbs. */
undidmsg = _("text add");
if (u->xflags == WAS_FINAL_LINE && !ISSET(NO_NEWLINES))
remove_magicline();
data = charalloc(strlen(f->data) - strlen(u->strdata) + 1);
strncpy(data, f->data, u->begin);
strcpy(&data[u->begin], &f->data[u->begin + strlen(u->strdata)]);
@ -907,6 +909,8 @@ void do_redo(void)
switch (u->type) {
case ADD:
redidmsg = _("text add");
if (u->xflags == WAS_FINAL_LINE && !ISSET(NO_NEWLINES))
new_magicline();
data = charalloc(strlen(f->data) + strlen(u->strdata) + 1);
strncpy(data, f->data, u->begin);
strcpy(&data[u->begin], u->strdata);
@ -1272,6 +1276,9 @@ void add_undo(undo_type action)
/* We need to start copying data into the undo buffer
* or we won't be able to restore it later. */
case ADD:
/* If a new magic line will be added, an undo should remove it. */
if (openfile->current == openfile->filebot && openfile->current_x == 0)
u->xflags = WAS_FINAL_LINE;
u->wassize--;
break;
case BACK: