justification fix: if the last line of a justified paragraph has a space
on the end of it, the space should be removed git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@1804 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
7ea39efdbd
commit
a9a6ce09d6
|
@ -42,9 +42,10 @@ CVS code -
|
||||||
feature is disabled if justification is disabled. (DLR)
|
feature is disabled if justification is disabled. (DLR)
|
||||||
- Modify the justification algorithm to work the same way as in
|
- Modify the justification algorithm to work the same way as in
|
||||||
the current version of Pico, i.e, add a space at the end of
|
the current version of Pico, i.e, add a space at the end of
|
||||||
each line of the justified paragraph except for the last one.
|
each line of the justified paragraph except for the last one,
|
||||||
Changes to justify_format() and do_justify(). (Note that the
|
and if there was a space at the end of the last one, remove
|
||||||
addition of spaces to justified lines means that
|
it. Changes to justify_format() and do_justify(). (Note that
|
||||||
|
the addition of spaces to justified lines means that
|
||||||
first_mod_line can no longer be used to reliably detect the
|
first_mod_line can no longer be used to reliably detect the
|
||||||
first modified line in a paragraph, since a line unmodified by
|
first modified line in a paragraph, since a line unmodified by
|
||||||
justify_format() may get a space tacked onto the end of it
|
justify_format() may get a space tacked onto the end of it
|
||||||
|
|
23
src/nano.c
23
src/nano.c
|
@ -2594,14 +2594,25 @@ int do_justify(int full_justify)
|
||||||
/* If the line we were on before still exists, and it was
|
/* If the line we were on before still exists, and it was
|
||||||
* not the last line of the paragraph, add a space to the
|
* not the last line of the paragraph, add a space to the
|
||||||
* end of it to replace the one removed or left out by
|
* end of it to replace the one removed or left out by
|
||||||
* justify_format(). */
|
* justify_format(). If it was the last line of the
|
||||||
if (current->prev != NULL && par_len > 1) {
|
* paragraph, and justify_format() left a space on the end
|
||||||
|
* of it, remove the space. */
|
||||||
|
if (current->prev != NULL) {
|
||||||
size_t prev_line_len = strlen(current->prev->data);
|
size_t prev_line_len = strlen(current->prev->data);
|
||||||
current->prev->data = charealloc(current->prev->data,
|
|
||||||
|
if (par_len > 1) {
|
||||||
|
current->prev->data = charealloc(current->prev->data,
|
||||||
prev_line_len + 2);
|
prev_line_len + 2);
|
||||||
current->prev->data[prev_line_len] = ' ';
|
current->prev->data[prev_line_len] = ' ';
|
||||||
current->prev->data[prev_line_len + 1] = '\0';
|
current->prev->data[prev_line_len + 1] = '\0';
|
||||||
totsize++;
|
totsize++;
|
||||||
|
} else if (par_len == 1 &&
|
||||||
|
current->prev->data[prev_line_len - 1] == ' ') {
|
||||||
|
current->prev->data = charealloc(current->prev->data,
|
||||||
|
prev_line_len);
|
||||||
|
current->prev->data[prev_line_len - 1] = '\0';
|
||||||
|
totsize--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue