tweaks: do a comparison a bit differently in do_output() and do_deletion()

Make it clearer we're comparing the number of rows, not string lengths.
master
David Lawrence Ramsey 2017-01-19 19:58:37 -06:00 committed by Benno Schulenberg
parent 3e22240fd5
commit 83ff644b6a
2 changed files with 6 additions and 6 deletions

View File

@ -1811,7 +1811,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
{ {
size_t current_len, i = 0; size_t current_len, i = 0;
#ifndef NANO_TINY #ifndef NANO_TINY
size_t orig_lenpt = 0; size_t orig_rows = 0;
#endif #endif
char *char_buf = charalloc(mb_cur_max()); char *char_buf = charalloc(mb_cur_max());
int char_len; int char_len;
@ -1820,7 +1820,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
#ifndef NANO_TINY #ifndef NANO_TINY
if (ISSET(SOFTWRAP)) if (ISSET(SOFTWRAP))
orig_lenpt = strlenpt(openfile->current->data); orig_rows = strlenpt(openfile->current->data) / editwincols;
#endif #endif
while (i < output_len) { while (i < output_len) {
@ -1886,7 +1886,7 @@ void do_output(char *output, size_t output_len, bool allow_cntrls)
/* If the number of screen rows that a softwrapped line occupies /* If the number of screen rows that a softwrapped line occupies
* has changed, we need a full refresh. */ * has changed, we need a full refresh. */
if (ISSET(SOFTWRAP) && refresh_needed == FALSE) if (ISSET(SOFTWRAP) && refresh_needed == FALSE)
if (strlenpt(openfile->current->data) / editwincols != orig_lenpt / editwincols) if ((strlenpt(openfile->current->data) / editwincols) != orig_rows)
refresh_needed = TRUE; refresh_needed = TRUE;
#endif #endif

View File

@ -92,7 +92,7 @@ char *invocation_error(const char *name)
void do_deletion(undo_type action) void do_deletion(undo_type action)
{ {
#ifndef NANO_TINY #ifndef NANO_TINY
size_t orig_lenpt = 0; size_t orig_rows = 0;
#endif #endif
assert(openfile->current != NULL && openfile->current->data != NULL && assert(openfile->current != NULL && openfile->current->data != NULL &&
@ -113,7 +113,7 @@ void do_deletion(undo_type action)
update_undo(action); update_undo(action);
if (ISSET(SOFTWRAP)) if (ISSET(SOFTWRAP))
orig_lenpt = strlenpt(openfile->current->data); orig_rows = strlenpt(openfile->current->data) / editwincols;
#endif #endif
/* Move the remainder of the line "in", over the current character. */ /* Move the remainder of the line "in", over the current character. */
@ -184,7 +184,7 @@ void do_deletion(undo_type action)
/* If the number of screen rows that a softwrapped line occupies /* If the number of screen rows that a softwrapped line occupies
* has changed, we need a full refresh. */ * has changed, we need a full refresh. */
if (ISSET(SOFTWRAP) && refresh_needed == FALSE) if (ISSET(SOFTWRAP) && refresh_needed == FALSE)
if (strlenpt(openfile->current->data) / editwincols != orig_lenpt / editwincols) if ((strlenpt(openfile->current->data) / editwincols) != orig_rows)
refresh_needed = TRUE; refresh_needed = TRUE;
#endif #endif