From: David Lawrence Ramsey Date: Thu, 10 Nov 2005 19:28:27 +0000 (+0000) Subject: fix more do_justify() breakage X-Git-Tag: v1.3.10~93 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=874ec8f259e490edfb411b4083f7d522b7c7fe1e;p=nano.git fix more do_justify() breakage git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3153 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- diff --git a/src/text.c b/src/text.c index 9a1c2d72..67d3fc08 100644 --- a/src/text.c +++ b/src/text.c @@ -1122,7 +1122,7 @@ void do_justify(bool full_justify) filestruct *first_par_line = NULL; /* Will be the first line of the justified paragraph. For * restoring after unjustify. */ - filestruct *last_par_line; + filestruct *last_par_line = NULL; /* Will be the line after the last line of the justified * paragraph, if any. Also for restoring after unjustify. */ bool filebot_inpar = FALSE; @@ -1154,8 +1154,6 @@ void do_justify(bool full_justify) if (full_justify) openfile->current = openfile->fileage; - last_par_line = openfile->current; - while (TRUE) { size_t i; /* Generic loop variable. */ @@ -1413,16 +1411,13 @@ void do_justify(bool full_justify) } /* We are now done justifying the paragraph or the file, so clean - * up. totsize, and current_y have been maintained above. Set - * last_par_line to the new end of the paragraph, update fileage, - * and renumber, since edit_refresh() needs the line numbers to be - * right (but only do the last two if we actually justified - * something). */ - last_par_line = openfile->current; + * up. current_y and totsize have been maintained above. If we + * actually justified something, renumber, since edit_refresh() + * needs the line numbers to be right, and set last_par_line to the + * new end of the paragraph. */ if (first_par_line != NULL) { - if (first_par_line->prev == NULL) - openfile->fileage = first_par_line; renumber(first_par_line); + last_par_line = openfile->current; } edit_refresh(); @@ -1445,13 +1440,6 @@ void do_justify(bool full_justify) if (!meta_key && !func_key && s_or_t && kbinput == NANO_UNJUSTIFY_KEY) { - /* Restore the justify we just did (ungrateful user!). */ - openfile->current = current_save; - openfile->current_x = current_x_save; - openfile->placewewant = pww_save; - openfile->current_y = current_y_save; - openfile->edittop = edittop_save; - /* Splice the justify buffer back into the file, but only if we * actually justified something. */ if (first_par_line != NULL) { @@ -1480,7 +1468,12 @@ void do_justify(bool full_justify) * partition. */ renumber(top_save); - /* Restore variables from before the justify. */ + /* Restore the justify we just did (ungrateful user!). */ + openfile->edittop = edittop_save; + openfile->current = current_save; + openfile->current_x = current_x_save; + openfile->placewewant = pww_save; + openfile->current_y = current_y_save; openfile->totsize = totsize_save; #ifndef NANO_SMALL if (openfile->mark_set) {