From 61b4eeda662d33f579c7118df05f56c506ef2ff9 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Wed, 8 Aug 2018 19:44:40 +0200 Subject: [PATCH] speller: do not replace the text when the temporary file did not change --- src/text.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/text.c b/src/text.c index fc1c592c..185f07f3 100644 --- a/src/text.c +++ b/src/text.c @@ -2872,6 +2872,9 @@ const char *do_alt_speller(char *tempfile_name) if (!WIFEXITED(alt_spell_status) || WEXITSTATUS(alt_spell_status) != 0) return invocation_error(alt_speller); + /* Stat the temporary file again, and only read it in when it changed. */ + stat(tempfile_name, &spellfileinfo); + if (spellfileinfo.st_mtime != timestamp) { #ifndef NANO_TINY /* Replace the marked text (or the entire text) of the current buffer * with the spell-checked text. */ @@ -2905,12 +2908,7 @@ const char *do_alt_speller(char *tempfile_name) openfile->current_x = strlen(openfile->current->data); openfile->placewewant = pww_save; adjust_viewport(STATIONARY); - - /* Stat the temporary file again, and mark the buffer as modified only - * if this file was changed since it was written. */ - stat(tempfile_name, &spellfileinfo); - if (spellfileinfo.st_mtime != timestamp) - set_modified(); + } #ifndef NANO_TINY /* Unblock SIGWINCHes again. */