fix bug in do_justify() in a better way: add on_next_line flag, used to
indicate when we've moved to the next line after justifying the current line, and only run the respacing routine when it's true; this keeps the respacing routine from erroneously being run more than once on the same line git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1840 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
01a6bf4f9a
commit
4693864a78
11
ChangeLog
11
ChangeLog
|
@ -28,12 +28,11 @@ CVS code -
|
||||||
--disable-justify again. (DLR; found by Mike Frysinger)
|
--disable-justify again. (DLR; found by Mike Frysinger)
|
||||||
- nano.c:
|
- nano.c:
|
||||||
do_justify()
|
do_justify()
|
||||||
- If all the text from the next line has been moved to the
|
- Add on_next_line flag, used to indicate when we've moved to
|
||||||
current line and the next line has been deleted, continue the
|
the next line after justifying the current line, and only run
|
||||||
justification loop from there and skip the respacing routine
|
the respacing routine when it's true. This keeps the
|
||||||
in order to avoid running it more than once on the same line
|
respacing routine from erroneously being run more than once on
|
||||||
(since it assumes that we've moved to the next line, which
|
the same line. (DLR)
|
||||||
isn't true in that case). (DLR)
|
|
||||||
do_exit()
|
do_exit()
|
||||||
- Tweak for efficiency. (David Benbennick)
|
- Tweak for efficiency. (David Benbennick)
|
||||||
- proto.h:
|
- proto.h:
|
||||||
|
|
34
src/nano.c
34
src/nano.c
|
@ -2382,6 +2382,10 @@ void do_justify(int full_justify)
|
||||||
/* When the paragraph gets modified, all lines from the changed
|
/* When the paragraph gets modified, all lines from the changed
|
||||||
* one down are stored in the cutbuffer. We back up the
|
* one down are stored in the cutbuffer. We back up the
|
||||||
* original to restore it later. */
|
* original to restore it later. */
|
||||||
|
int allow_respacing;
|
||||||
|
/* Whether we should change the spacing at the end of a line
|
||||||
|
* after justifying it. This should be TRUE whenever we move
|
||||||
|
* to the next line after justifying the current line. */
|
||||||
|
|
||||||
/* We save these global variables to be restored if the user
|
/* We save these global variables to be restored if the user
|
||||||
* unjustifies. Note we don't need to save totlines. */
|
* unjustifies. Note we don't need to save totlines. */
|
||||||
|
@ -2440,6 +2444,11 @@ void do_justify(int full_justify)
|
||||||
int break_pos;
|
int break_pos;
|
||||||
/* Where we will break the line. */
|
/* Where we will break the line. */
|
||||||
|
|
||||||
|
/* We'll be moving to the next line after justifying the
|
||||||
|
* current line in almost all cases, so allow changing the
|
||||||
|
* spacing at the ends of justified lines by default. */
|
||||||
|
allow_respacing = TRUE;
|
||||||
|
|
||||||
indent_len = quote_len + indent_length(current->data +
|
indent_len = quote_len + indent_length(current->data +
|
||||||
quote_len);
|
quote_len);
|
||||||
|
|
||||||
|
@ -2521,6 +2530,8 @@ void do_justify(int full_justify)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
null_at(¤t->data, break_pos);
|
null_at(¤t->data, break_pos);
|
||||||
|
|
||||||
|
/* Go to the next line. */
|
||||||
current = current->next;
|
current = current->next;
|
||||||
} else if (display_len < fill && par_len > 1) {
|
} else if (display_len < fill && par_len > 1) {
|
||||||
size_t next_line_len;
|
size_t next_line_len;
|
||||||
|
@ -2570,9 +2581,11 @@ void do_justify(int full_justify)
|
||||||
totsize -= indent_len;
|
totsize -= indent_len;
|
||||||
current_y--;
|
current_y--;
|
||||||
|
|
||||||
/* Don't go to the next line, since there isn't one
|
/* Don't go to the next line. Accordingly, don't
|
||||||
* anymore. Just continue the loop from here. */
|
* allow changing the spacing at the end of the
|
||||||
continue;
|
* previous justified line, since we've already done
|
||||||
|
* it once. */
|
||||||
|
allow_respacing = FALSE;
|
||||||
} else {
|
} else {
|
||||||
charmove(current->next->data + indent_len,
|
charmove(current->next->data + indent_len,
|
||||||
current->next->data + indent_len + break_pos + 1,
|
current->next->data + indent_len + break_pos + 1,
|
||||||
|
@ -2587,13 +2600,14 @@ void do_justify(int full_justify)
|
||||||
/* Go to the next line. */
|
/* Go to the next line. */
|
||||||
current = current->next;
|
current = current->next;
|
||||||
|
|
||||||
/* If we've gone to the next line, the line we were on
|
/* We've moved to the next line after justifying the
|
||||||
* before still exists, and it was not the last line of the
|
* current line. If the justified line was not the last
|
||||||
* paragraph, add a space to the end of it to replace the
|
* line of the paragraph, add a space to the end of it to
|
||||||
* one removed or left out by justify_format(). If it was
|
* replace the one removed or left out by justify_format().
|
||||||
* the last line of the paragraph, and justify_format() left
|
* If it was the last line of the paragraph, and
|
||||||
* a space on the end of it, remove the space. */
|
* justify_format() left a space on the end of it, remove
|
||||||
if (current->prev != NULL) {
|
* the space. */
|
||||||
|
if (allow_respacing) {
|
||||||
size_t prev_line_len = strlen(current->prev->data);
|
size_t prev_line_len = strlen(current->prev->data);
|
||||||
|
|
||||||
if (par_len > 1) {
|
if (par_len > 1) {
|
||||||
|
|
Loading…
Reference in New Issue