diff --git a/ChangeLog b/ChangeLog index 0242ce932199243b7375f0e3481b8e1ed66f591b..8a78567abe6b72de309671a730589fddd9090197 100644 --- a/ChangeLog +++ b/ChangeLog @@ -37,8 +37,9 @@ CVS code - characters and escape sequences are supported. (DLR) - Disable "Where Is Next" in tiny mode. (DLR) - Added the ability to justify the entire file at once, which - Pico has via ^W^J. Changes to do_justify(); new functions - do_justify_void() and do_full_justify(). (DLR) + Pico has via ^W^J. Changes to backup_lines() and + do_justify(); new functions do_justify_void() and + do_full_justify(). (DLR) - Modify the justification algorithm to work the same way as in the current version of Pico, i.e, add a space at the end of each line of the justified paragraph except for the last one, diff --git a/src/nano.c b/src/nano.c index d8217002131f5fab5243fcb6a2801e0b1f1bb8f1..e469226e1f81f913f6050da871d9078caf650f9f 100644 --- a/src/nano.c +++ b/src/nano.c @@ -2053,7 +2053,6 @@ filestruct *backup_lines(filestruct *first_line, size_t par_len, size_t if (alice == mark_beginbuf) mark_beginbuf = bob; #endif - justify_format(bob, quote_len + indent_length(bob->data + quote_len)); assert(alice != NULL && bob != NULL); add_to_cutbuffer(alice, FALSE); @@ -2458,15 +2457,18 @@ int do_justify(int full_justify) indent_len = quote_len + indent_length(current->data + quote_len); - /* We now call backup_lines(), which copies the original - * paragraph to the cutbuffer for unjustification and then - * calls justify_format() on each line of the original - * paragraph. justify_format() removes excess spaces from - * the line, and changes tabs to spaces. */ + /* If we haven't already done it, copy the original + * paragraph to the cutbuffer for unjustification. */ if (first_par_line == NULL) first_par_line = backup_lines(current, full_justify ? filebot->lineno - current->lineno : par_len, quote_len); + /* Now we call justify_format() on the current line of the + * paragraph, which will remove excess spaces from it and + * change tabs to spaces. */ + justify_format(current, quote_len + + indent_length(current->data + quote_len)); + line_len = strlen(current->data); display_len = strlenpt(current->data);