Commit 5aa1df37 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

files: recompute the multidata only when the applicable syntax changed

parent ca2c808f
Showing with 19 additions and 15 deletions
+19 -15
...@@ -2122,26 +2122,30 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type ...@@ -2122,26 +2122,30 @@ bool write_file(const char *name, FILE *f_open, bool tmp, append_type
} }
if (!tmp && append == OVERWRITE) { if (!tmp && append == OVERWRITE) {
if (!nonamechange) { /* If we must set the filename, and it changed, adjust things. */
filestruct *line; if (!nonamechange && strcmp(openfile->filename, realname) != 0) {
#ifndef DISABLE_COLOR
char *syntaxname = openfile->syntax ? openfile->syntax->name : "";
filestruct *line = openfile->fileage;
#endif
openfile->filename = mallocstrcpy(openfile->filename, realname);
openfile->filename = mallocstrcpy(openfile->filename,
realname);
#ifndef DISABLE_COLOR #ifndef DISABLE_COLOR
/* Discard all the now (possibly) obsolete multidata. */ /* See if the applicable syntax has changed. */
for (line = openfile->fileage; line != NULL; line = line->next) { color_update();
color_init();
/* If the syntax changed, discard and recompute the multidata. */
if (openfile->syntax &&
strcmp(syntaxname, openfile->syntax->name) != 0) {
for (; line != NULL; line = line->next) {
free(line->multidata); free(line->multidata);
line->multidata = NULL; line->multidata = NULL;
} }
/* We might have changed the filename, so update the colors
* to account for it, and then make sure we're using them. */
color_update();
color_init();
precalc_multicolorinfo(); precalc_multicolorinfo();
}
/* If color syntaxes are available and turned on, we need to /* If color syntaxes are available and turned on, refresh. */
* call edit_refresh(). */
if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX)) if (openfile->colorstrings != NULL && !ISSET(NO_COLOR_SYNTAX))
edit_refresh(); edit_refresh();
#endif #endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment