From: Benno Schulenberg Date: Thu, 3 Dec 2015 09:17:06 +0000 (+0000) Subject: Discarding the entire undo stack, to prevent nano from making mistakes X-Git-Tag: v2.5.0~9 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=4bc8ff1e6d4550251e9216fe59ff8cbb8ee2b27d;p=nano.git Discarding the entire undo stack, to prevent nano from making mistakes when trying to undo edits after an indentation change. This works around Savannah bug #46591. git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5474 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/ChangeLog b/ChangeLog index ca9a5720..e791f69d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,9 @@ * 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. + * src/text.c (do_indent): Also here discard the entire undo stack, to + prevent nano from making mistakes when trying to undo edits after an + indentation change. This works around Savannah bug #46591. 2015-12-02 Benno Schulenberg * doc/syntax/python.nanorc: Don't colour triple quotes by themselves. diff --git a/src/text.c b/src/text.c index f0fe45dd..d11de946 100644 --- a/src/text.c +++ b/src/text.c @@ -394,6 +394,11 @@ void do_indent(ssize_t cols) free(line_indent); if (indent_changed) { + /* Throw away the undo stack, to prevent making mistakes when + * the user tries to undo something in the reindented text. */ + discard_until(NULL); + openfile->current_undo = NULL; + /* Mark the file as modified. */ set_modified();