From a853e2d6500e417dac1b27c03c121b4e46695d80 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Tue, 22 Mar 2005 02:17:36 +0000 Subject: [PATCH] in do_justify(), move break_pos after the space earlier, as do_wrap() does with wrap_loc, as it's more efficient git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2414 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- src/nano.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/nano.c b/src/nano.c index ba088228..db1ac411 100644 --- a/src/nano.c +++ b/src/nano.c @@ -3113,9 +3113,11 @@ void do_justify(bool full_justify) if (break_pos == -1 || break_pos + indent_len == line_len) break; - break_pos += indent_len; + /* Move forward to the character after the indentation and + * just after the space. */ + break_pos += indent_len + 1; - assert(break_pos < line_len); + assert(break_pos <= line_len); /* Make a new line, and copy the text after where we're * going to break this line to the beginning of the new @@ -3132,11 +3134,13 @@ void do_justify(bool full_justify) ) indent_len = 0; - current->next->data = charalloc(indent_len + line_len - + /* Copy the text after where we're going to break the + * current line to the next line. */ + current->next->data = charalloc(indent_len + 1 + line_len - break_pos); charcpy(current->next->data, indent_string, indent_len); strcpy(current->next->data + indent_len, current->data + - break_pos + 1); + break_pos); par_len++; totlines++; @@ -3147,12 +3151,12 @@ void do_justify(bool full_justify) * in the current line. */ if (mark_beginbuf == current && mark_beginx > break_pos) { mark_beginbuf = current->next; - mark_beginx -= break_pos + 1 - indent_len; + mark_beginx -= break_pos - indent_len; } #endif - /* Break the line at the character just after the space. */ - null_at(¤t->data, break_pos + 1); + /* Break the current line. */ + null_at(¤t->data, break_pos); /* Go to the next line. */ par_len--; -- 2.39.5