tweaks: move the check for beginning-of-paragraph to a better place
Only the first search for a paragraph needs to check whether we're currently in the middle of a paragraph. When the 'while' loop for a full justify is executed, all calls of find_paragraph() start either on the first line of a paragraph or between two paragraphs.master
parent
2c83047842
commit
500c41b83b
10
src/text.c
10
src/text.c
|
@ -2049,10 +2049,6 @@ bool find_paragraph(filestruct **firstline, bool *touched_eof,
|
|||
while (!inpar(line) && line->next != NULL)
|
||||
line = line->next;
|
||||
|
||||
/* When in a paragraph but not at its beginning, move back to its first line. */
|
||||
if (inpar(line) && !begpar(line, 0))
|
||||
do_para_begin(&line);
|
||||
|
||||
*firstline = line;
|
||||
|
||||
/* Now move down to just beyond the end of the paragraph, if possible. */
|
||||
|
@ -2228,11 +2224,13 @@ void do_justify(bool full_justify)
|
|||
size_t was_current_x = openfile->current_x;
|
||||
#endif
|
||||
|
||||
/* If we're justifying the entire file, start at the beginning. */
|
||||
/* When justifying the entire buffer, start at the top. Otherwise, when
|
||||
* in a paragraph but not at its beginning, move back to its first line. */
|
||||
if (full_justify) {
|
||||
openfile->current = openfile->fileage;
|
||||
openfile->current_x = 0;
|
||||
}
|
||||
} else if (inpar(openfile->current) && !begpar(openfile->current, 0))
|
||||
do_para_begin(&openfile->current);
|
||||
|
||||
/* Find the first line of the paragraph(s) to be justified.
|
||||
* If the search failed, it means that there are no paragraph(s) to
|
||||
|
|
Loading…
Reference in New Issue