mirror of
git://git.sv.gnu.org/nano.git
synced 2024-11-22 21:01:24 +03:00
justify: trim the leading blanks of a marked region at the right moment
This fixes https://savannah.gnu.org/bugs/?57977.
Bug existed since commit 5310a355
from three hours ago.
This commit is contained in:
parent
8f3ea23ece
commit
c457f744ef
17
src/text.c
17
src/text.c
@ -1862,15 +1862,9 @@ void do_justify(bool full_justify)
|
||||
|
||||
if (openfile->mark) {
|
||||
size_t line_len = strlen(cutbuffer->data);
|
||||
size_t white_len = indent_length(cutbuffer->data);
|
||||
linestruct *line;
|
||||
|
||||
/* Trim any whitespace at the start of the extracted region. */
|
||||
if (white_len > 0) {
|
||||
memmove(cutbuffer->data, cutbuffer->data + white_len,
|
||||
line_len - white_len + 1);
|
||||
line_len -= white_len;
|
||||
}
|
||||
size_t white_len;
|
||||
char *afterlead;
|
||||
|
||||
/* If the marked region started in the middle of a line, and this line
|
||||
* has a leading part, then prepend this same leading part also to the
|
||||
@ -1881,6 +1875,13 @@ void do_justify(bool full_justify)
|
||||
strncpy(cutbuffer->data, the_lead, lead_len);
|
||||
}
|
||||
|
||||
afterlead = cutbuffer->data + lead_len;
|
||||
white_len = indent_length(afterlead);
|
||||
|
||||
/* If the marked region started with whitespace, trim it. */
|
||||
if (white_len > 0)
|
||||
memmove(afterlead, afterlead + white_len, line_len - white_len + 1);
|
||||
|
||||
/* Now justify the extracted region. */
|
||||
concat_paragraph(&cutbuffer, linecount);
|
||||
squeeze(cutbuffer, lead_len);
|
||||
|
Loading…
Reference in New Issue
Block a user