From b5f15cb574cfbd02f633d371d1139a4ded5ea82c Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Mon, 30 Jul 2018 16:38:53 -0500 Subject: [PATCH] speller: make replace_buffer() use the cutting functions directly --- src/files.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/files.c b/src/files.c index 9567a9ae..22e89e82 100644 --- a/src/files.c +++ b/src/files.c @@ -512,6 +512,7 @@ void replace_buffer(const char *filename) { FILE *f; int descriptor; + filestruct *was_cutbuffer = cutbuffer; /* Open the file quietly. */ descriptor = open_file(filename, FALSE, TRUE, &f); @@ -520,15 +521,16 @@ void replace_buffer(const char *filename) if (descriptor < 0) return; - /* Reinitialize the text of the current buffer. */ - free_filestruct(openfile->fileage); - initialize_buffer_text(); + /* Throw away the text of the file. */ + cutbuffer = NULL; + openfile->current = openfile->fileage; + openfile->current_x = 0; + do_cut_text(FALSE, FALSE, TRUE); + free_filestruct(cutbuffer); + cutbuffer = was_cutbuffer; /* Insert the processed file into its place. */ read_file(f, descriptor, filename, FALSE); - - /* Put current at a place that is certain to exist. */ - openfile->current = openfile->fileage; } #ifndef NANO_TINY