commit 0f2b0ffbd3afcc839d8c9af56ca699881ccb0e22
parent f2f901c895008619e955f47061707faded207c82
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 31 May 2018 16:27:13 +0200
tweaks: reshuffle a condition, and adjust a comment and some indentation
Diffstat:
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/src/files.c b/src/files.c
@@ -1933,16 +1933,16 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
goto cleanup_and_exit;
}
- if (method == OVERWRITE && !tmp) {
- /* If we must set the filename, and it changed, adjust things. */
- if (fullbuffer && strcmp(openfile->filename, realname) != 0) {
+ /* When having written an entire buffer, update some administrivia. */
+ if (fullbuffer && method == OVERWRITE && !tmp) {
+ /* If the filename was changed, check if this means a new syntax. */
+ if (strcmp(openfile->filename, realname) != 0) {
#ifdef ENABLE_COLOR
const char *oldname, *newname;
oldname = openfile->syntax ? openfile->syntax->name : "";
#endif
openfile->filename = mallocstrcpy(openfile->filename, realname);
-
#ifdef ENABLE_COLOR
/* See if the applicable syntax has changed. */
color_update();
@@ -1959,29 +1959,27 @@ bool write_file(const char *name, FILE *f_open, bool tmp,
line->multidata = NULL;
line = line->next;
}
+
precalc_multicolorinfo();
refresh_needed = TRUE;
}
#endif
}
-
- if (fullbuffer) {
#ifndef NANO_TINY
- /* Get or update the stat info to reflect the current state. */
- stat_with_alloc(realname, &openfile->current_stat);
+ /* 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;
+ /* 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);
- }
+ openfile->modified = FALSE;
+ titlebar(NULL);
}
if (!tmp)
statusline(HUSH, P_("Wrote %zu line", "Wrote %zu lines",
- lineswritten), lineswritten);
+ lineswritten), lineswritten);
retval = TRUE;
cleanup_and_exit: