2015-12-03 Benno Schulenberg <bensberg@justemail.net>
* src/text.c (discard_until): Move the trimming of the undo stack
into a separate function, so it can be used elsewhere.
+ * src/text.c (do_justify): Discard the entire undo stack, to prevent
+ nano from dying (or making mistakes) when trying to undo edits after
+ a justification. This works around Savannah bug #45531.
2015-12-02 Benno Schulenberg <bensberg@justemail.net>
* doc/syntax/python.nanorc: Don't colour triple quotes by themselves.
while (dropit != NULL && dropit != thisone) {
openfile->undotop = dropit->next;
free(dropit->strdata);
- if (dropit->cutbuffer)
+ if (dropit->cutbuffer != NULL)
free_filestruct(dropit->cutbuffer);
free(dropit);
dropit = openfile->undotop;
edit_refresh_needed = TRUE;
}
} else {
+ /* Put the keystroke back into the queue. */
unget_kbinput(kbinput, meta_key, func_key);
+ /* Throw away the entire undo stack, to prevent a crash when
+ * the user tries to undo something in the justified text. */
+ discard_until(NULL);
+ openfile->current_undo = NULL;
+
/* Blow away the text in the justify buffer. */
free_filestruct(jusbuffer);
jusbuffer = NULL;