Commit b2d1c5f5 authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

fix yet more do_justify() breakage

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3146 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 14 additions and 5 deletions
+14 -5
...@@ -974,9 +974,9 @@ filestruct *backup_lines(filestruct *first_line, size_t par_len) ...@@ -974,9 +974,9 @@ filestruct *backup_lines(filestruct *first_line, size_t par_len)
} }
#endif #endif
/* Note: par_len will be one greater than the number of lines /* par_len will be one greater than the number of lines between
* between current and filebot if filebot is the last line to be * current and filebot if filebot is the last line in the
* backed up. */ * paragraph. */
assert(par_len > 0 && openfile->current->lineno + par_len <= assert(par_len > 0 && openfile->current->lineno + par_len <=
filebot->lineno + 1); filebot->lineno + 1);
...@@ -1123,6 +1123,9 @@ void do_justify(bool full_justify) ...@@ -1123,6 +1123,9 @@ void do_justify(bool full_justify)
filestruct *last_par_line; filestruct *last_par_line;
/* 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;
/* Whether the text at filebot is part of the current
* paragraph. */
/* We save these variables to be restored if the user /* We save these variables to be restored if the user
* unjustifies. */ * unjustifies. */
...@@ -1199,6 +1202,12 @@ void do_justify(bool full_justify) ...@@ -1199,6 +1202,12 @@ void do_justify(bool full_justify)
} }
} }
/* par_len will be one greater than the number of lines between
* current and filebot if filebot is the last line in the
* paragraph. Set filebot_inpar to TRUE if this is the case. */
filebot_inpar = (openfile->current->lineno + par_len ==
openfile->filebot->lineno + 1);
/* If we haven't already done it, copy the original paragraph(s) /* If we haven't already done it, copy the original paragraph(s)
* to the justify buffer. */ * to the justify buffer. */
if (first_par_line == NULL) if (first_par_line == NULL)
...@@ -1449,8 +1458,8 @@ void do_justify(bool full_justify) ...@@ -1449,8 +1458,8 @@ void do_justify(bool full_justify)
/* Partition the filestruct so that it contains only the /* Partition the filestruct so that it contains only the
* text of the justified paragraph. */ * text of the justified paragraph. */
filepart = partition_filestruct(first_par_line, 0, filepart = partition_filestruct(first_par_line, 0,
last_par_line, (last_par_line == openfile->filebot) ? last_par_line, (filebot_inpar && last_par_line ==
strlen(last_par_line->data) : 0); openfile->filebot) ? strlen(last_par_line->data) : 0);
/* Remove the text of the justified paragraph, and /* Remove the text of the justified paragraph, and
* replace it with the text in the justify buffer. */ * replace it with the text in the justify buffer. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment