nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit b5f15cb574cfbd02f633d371d1139a4ded5ea82c
parent 4c66a6259cf45fbef0eb14d00488fac8c469ce7f
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date:   Mon, 30 Jul 2018 16:38:53 -0500

speller: make replace_buffer() use the cutting functions directly

Diffstat:
Msrc/files.c | 14++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git 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