fix more do_justify() breakage

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3153 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2005-11-10 19:28:27 +00:00
parent 985d586c3a
commit 874ec8f259
1 changed files with 12 additions and 19 deletions

View File

@ -1122,7 +1122,7 @@ void do_justify(bool full_justify)
filestruct *first_par_line = NULL; filestruct *first_par_line = NULL;
/* Will be the first line of the justified paragraph. For /* Will be the first line of the justified paragraph. For
* restoring after unjustify. */ * restoring after unjustify. */
filestruct *last_par_line; filestruct *last_par_line = NULL;
/* Will be the line after the last line of the justified /* Will be the line after the last line of the justified
* paragraph, if any. Also for restoring after unjustify. */ * paragraph, if any. Also for restoring after unjustify. */
bool filebot_inpar = FALSE; bool filebot_inpar = FALSE;
@ -1154,8 +1154,6 @@ void do_justify(bool full_justify)
if (full_justify) if (full_justify)
openfile->current = openfile->fileage; openfile->current = openfile->fileage;
last_par_line = openfile->current;
while (TRUE) { while (TRUE) {
size_t i; size_t i;
/* Generic loop variable. */ /* 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 /* We are now done justifying the paragraph or the file, so clean
* up. totsize, and current_y have been maintained above. Set * up. current_y and totsize have been maintained above. If we
* last_par_line to the new end of the paragraph, update fileage, * actually justified something, renumber, since edit_refresh()
* and renumber, since edit_refresh() needs the line numbers to be * needs the line numbers to be right, and set last_par_line to the
* right (but only do the last two if we actually justified * new end of the paragraph. */
* something). */
last_par_line = openfile->current;
if (first_par_line != NULL) { if (first_par_line != NULL) {
if (first_par_line->prev == NULL)
openfile->fileage = first_par_line;
renumber(first_par_line); renumber(first_par_line);
last_par_line = openfile->current;
} }
edit_refresh(); edit_refresh();
@ -1445,13 +1440,6 @@ void do_justify(bool full_justify)
if (!meta_key && !func_key && s_or_t && if (!meta_key && !func_key && s_or_t &&
kbinput == NANO_UNJUSTIFY_KEY) { 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 /* Splice the justify buffer back into the file, but only if we
* actually justified something. */ * actually justified something. */
if (first_par_line != NULL) { if (first_par_line != NULL) {
@ -1480,7 +1468,12 @@ void do_justify(bool full_justify)
* partition. */ * partition. */
renumber(top_save); 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; openfile->totsize = totsize_save;
#ifndef NANO_SMALL #ifndef NANO_SMALL
if (openfile->mark_set) { if (openfile->mark_set) {