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
#ifdef ENABLE_WRAPPING
/* Wrap the line when needed, and if so, schedule a refresh. */
if (ISSET(BREAK_LONG_LINES) && do_wrap())
refresh_needed = TRUE;
if (ISSET(BREAK_LONG_LINES))
do_wrap();
#endif
#ifndef NANO_TINY

View File

@ -493,7 +493,7 @@ void update_multiline_undo(ssize_t lineno, char *indentation);
void update_undo(undo_type action);
#endif /* !NANO_TINY */
#ifdef ENABLE_WRAPPING
bool do_wrap(void);
void do_wrap(void);
#endif
#if defined(ENABLE_HELP) || defined(ENABLED_WRAPORJUSTIFY)
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
/* When the current line is overlong, hard-wrap it at the furthest possible
* whitespace character, and (if possible) prepend the remainder of the line
* to the next line. Return TRUE if wrapping occurred, and FALSE otherwise. */
bool do_wrap(void)
* whitespace character, and prepend the excess part to an "overflow" line
* (when it already exists, otherwise create one). */
void do_wrap(void)
{
linestruct *line = openfile->current;
/* 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 (wrap_loc < 0 || lead_len + wrap_loc == line_len)
return FALSE;
return;
/* Adjust the wrap location to its position in the full line,
* 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. */
if (line->data[wrap_loc] == '\0')
return FALSE;
return;
#ifndef NANO_TINY
add_undo(SPLIT_BEGIN, NULL);
@ -1360,7 +1360,7 @@ bool do_wrap(void)
add_undo(SPLIT_END, NULL);
#endif
return TRUE;
refresh_needed = TRUE;
}
#endif /* ENABLE_WRAPPING */