nano

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

commit 735757b0c12e67297a6379269af360aba609f7de
parent 09b919a68f30e7c527dbcc421842474e46fbeef5
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Wed, 24 Mar 2021 12:00:34 +0100

tweaks: set the file format only when unset, so it doesn't need saving

When inserting a file into the current buffer, the 'fmt' element will
already be set.  When we avoid overwriting the current value of 'fmt'
(when it's other than UNSPECIFIED), we don't need to save and restore
the value when inserting a file.

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

diff --git a/src/files.c b/src/files.c @@ -824,10 +824,6 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable) statusline(HUSH, P_("Read %zu line", "Read %zu lines", num_lines), num_lines); -#ifndef NANO_TINY - openfile->fmt = format; -#endif - /* If we inserted less than a screenful, don't center the cursor. */ if (undoable && less_than_a_screenful(was_lineno, was_leftedge)) focusing = FALSE; @@ -842,6 +838,8 @@ void read_file(FILE *f, int fd, const char *filename, bool undoable) if (ISSET(MAKE_IT_UNIX)) openfile->fmt = NIX_FILE; + else if (openfile->fmt == UNSPECIFIED) + openfile->fmt = format; #endif } @@ -1121,9 +1119,6 @@ void do_insertfile(bool execute) #ifdef ENABLE_MULTIBUFFER bool was_multibuffer = ISSET(MULTIBUFFER); #endif -#ifndef NANO_TINY - format_type was_fmt = openfile->fmt; -#endif /* Display newlines in filenames as ^J. */ as_an_at = FALSE; @@ -1293,10 +1288,7 @@ void do_insertfile(bool execute) if (openfile->current->lineno != was_current_lineno || openfile->current_x != was_current_x) set_modified(); -#ifndef NANO_TINY - /* Ensure that the buffer retains the format that it had. */ - openfile->fmt = was_fmt; -#endif + refresh_needed = TRUE; }