text: set and reset the Modified state correctly when undoing/redoing

Unset the "Modified" marker only at the point where the file was last
saved -- if there is such a point, because it can be missing when the
undo stack was discarded.

This fixes https://savannah.gnu.org/bugs/?52689.
Reported-by: Liu Hao <lh_mouse@126.com>

Original-idea-by: Brand Huntsman <alpha@qzx.com>
This commit is contained in:
Benno Schulenberg
2017-12-18 20:08:06 +01:00
parent 31fe0753e3
commit dc3618a127
3 changed files with 20 additions and 11 deletions

View File

@@ -99,8 +99,8 @@ void make_new_buffer(void)
openfile->undotop = NULL;
openfile->current_undo = NULL;
openfile->last_saved = NULL;
openfile->last_action = OTHER;
openfile->pristine = TRUE;
openfile->current_stat = NULL;
openfile->lock_filename = NULL;
@@ -1953,6 +1953,10 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
#ifndef NANO_TINY
/* Get or update the stat info to reflect the current state. */
stat_with_alloc(realname, &openfile->current_stat);
/* Record at which point in the undo stack the file was saved. */
openfile->last_saved = openfile->current_undo;
openfile->last_action = OTHER;
#endif
openfile->modified = FALSE;
titlebar(NULL);