Moving the trimming of the undo stack into a separate function.
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5472 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
a41968eeef
commit
ee5cdcbce5
|
@ -1,3 +1,7 @@
|
||||||
|
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.
|
||||||
|
|
||||||
2015-12-02 Benno Schulenberg <bensberg@justemail.net>
|
2015-12-02 Benno Schulenberg <bensberg@justemail.net>
|
||||||
* doc/syntax/python.nanorc: Don't colour triple quotes by themselves.
|
* doc/syntax/python.nanorc: Don't colour triple quotes by themselves.
|
||||||
* doc/syntax/python.nanorc: Treat backslashed quotes properly, and
|
* doc/syntax/python.nanorc: Treat backslashed quotes properly, and
|
||||||
|
|
24
src/text.c
24
src/text.c
|
@ -904,6 +904,21 @@ bool execute_command(const char *command)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Discard undo items that are newer than thisone, or all if NULL. */
|
||||||
|
void discard_until(undo *thisone)
|
||||||
|
{
|
||||||
|
undo *dropit = openfile->undotop;
|
||||||
|
|
||||||
|
while (dropit != NULL && dropit != thisone) {
|
||||||
|
openfile->undotop = dropit->next;
|
||||||
|
free(dropit->strdata);
|
||||||
|
if (dropit->cutbuffer)
|
||||||
|
free_filestruct(dropit->cutbuffer);
|
||||||
|
free(dropit);
|
||||||
|
dropit = openfile->undotop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Add a new undo struct to the top of the current pile. */
|
/* Add a new undo struct to the top of the current pile. */
|
||||||
void add_undo(undo_type action)
|
void add_undo(undo_type action)
|
||||||
{
|
{
|
||||||
|
@ -918,14 +933,7 @@ void add_undo(undo_type action)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Blow away newer undo items if we add somewhere in the middle. */
|
/* Blow away newer undo items if we add somewhere in the middle. */
|
||||||
while (openfile->undotop != NULL && openfile->undotop != u) {
|
discard_until(u);
|
||||||
undo *dropit = openfile->undotop;
|
|
||||||
openfile->undotop = openfile->undotop->next;
|
|
||||||
free(dropit->strdata);
|
|
||||||
if (dropit->cutbuffer)
|
|
||||||
free_filestruct(dropit->cutbuffer);
|
|
||||||
free(dropit);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, " >> Adding an undo...\n");
|
fprintf(stderr, " >> Adding an undo...\n");
|
||||||
|
|
Loading…
Reference in New Issue