tweaks: just let do_wrap() set 'refresh_needed' instead of returning TRUE

This gets rid of performing an action in the condition of an 'if'.
master
Benno Schulenberg 2021-10-21 11:56:22 +02:00
parent 5d285ca896
commit 918ce1afa3
3 changed files with 9 additions and 10 deletions

View File

@ -1465,9 +1465,8 @@ void inject(char *burst, size_t count)
#endif #endif
#ifdef ENABLE_WRAPPING #ifdef ENABLE_WRAPPING
/* Wrap the line when needed, and if so, schedule a refresh. */ if (ISSET(BREAK_LONG_LINES))
if (ISSET(BREAK_LONG_LINES) && do_wrap()) do_wrap();
refresh_needed = TRUE;
#endif #endif
#ifndef NANO_TINY #ifndef NANO_TINY

View File

@ -493,7 +493,7 @@ void update_multiline_undo(ssize_t lineno, char *indentation);
void update_undo(undo_type action); void update_undo(undo_type action);
#endif /* !NANO_TINY */ #endif /* !NANO_TINY */
#ifdef ENABLE_WRAPPING #ifdef ENABLE_WRAPPING
bool do_wrap(void); void do_wrap(void);
#endif #endif
#if defined(ENABLE_HELP) || defined(ENABLED_WRAPORJUSTIFY) #if defined(ENABLE_HELP) || defined(ENABLED_WRAPORJUSTIFY)
ssize_t break_line(const char *textstart, ssize_t goal, bool snap_at_nl); ssize_t break_line(const char *textstart, ssize_t goal, bool snap_at_nl);

View File

@ -1212,9 +1212,9 @@ void update_undo(undo_type action)
#ifdef ENABLE_WRAPPING #ifdef ENABLE_WRAPPING
/* When the current line is overlong, hard-wrap it at the furthest possible /* When the current line is overlong, hard-wrap it at the furthest possible
* whitespace character, and (if possible) prepend the remainder of the line * whitespace character, and prepend the excess part to an "overflow" line
* to the next line. Return TRUE if wrapping occurred, and FALSE otherwise. */ * (when it already exists, otherwise create one). */
bool do_wrap(void) void do_wrap(void)
{ {
linestruct *line = openfile->current; linestruct *line = openfile->current;
/* The line to be wrapped, if needed and possible. */ /* The line to be wrapped, if needed and possible. */
@ -1243,7 +1243,7 @@ bool do_wrap(void)
/* If no wrapping point was found before end-of-line, we don't wrap. */ /* If no wrapping point was found before end-of-line, we don't wrap. */
if (wrap_loc < 0 || lead_len + wrap_loc == line_len) if (wrap_loc < 0 || lead_len + wrap_loc == line_len)
return FALSE; return;
/* Adjust the wrap location to its position in the full line, /* Adjust the wrap location to its position in the full line,
* and step forward to the character just after the blank. */ * and step forward to the character just after the blank. */
@ -1251,7 +1251,7 @@ bool do_wrap(void)
/* When now at end-of-line, no need to wrap. */ /* When now at end-of-line, no need to wrap. */
if (line->data[wrap_loc] == '\0') if (line->data[wrap_loc] == '\0')
return FALSE; return;
#ifndef NANO_TINY #ifndef NANO_TINY
add_undo(SPLIT_BEGIN, NULL); add_undo(SPLIT_BEGIN, NULL);
@ -1360,7 +1360,7 @@ bool do_wrap(void)
add_undo(SPLIT_END, NULL); add_undo(SPLIT_END, NULL);
#endif #endif
return TRUE; refresh_needed = TRUE;
} }
#endif /* ENABLE_WRAPPING */ #endif /* ENABLE_WRAPPING */