anchor: during full justification preserve anchors as during single ones

When a single paragraph is justified, any anchor on any of its lines
gets moved to its first line.  Let a full justification do the same
for each of the paragraphs.

This fixes https://savannah.gnu.org/bugs/?58272 in a better way.
master
Benno Schulenberg 2020-04-30 16:02:27 +02:00
parent 703cebaaac
commit 11f099e1da
1 changed files with 4 additions and 5 deletions

View File

@ -1564,7 +1564,9 @@ void concat_paragraph(linestruct *line, size_t count)
line->data = charealloc(line->data, line->data = charealloc(line->data,
line_len + next_line_len - next_lead_len + 1); line_len + next_line_len - next_lead_len + 1);
strcat(line->data, next_line->data + next_lead_len); strcat(line->data, next_line->data + next_lead_len);
#ifndef NANO_TINY
line->has_anchor |= next_line->has_anchor;
#endif
unlink_node(next_line); unlink_node(next_line);
count--; count--;
} }
@ -1733,8 +1735,6 @@ void do_justify(bool full_justify)
/* Whether the mark (if any) is before the cursor. */ /* Whether the mark (if any) is before the cursor. */
bool before_eol = FALSE; bool before_eol = FALSE;
/* Whether the end of a marked region is before the end of its line. */ /* Whether the end of a marked region is before the end of its line. */
bool had_anchor = FALSE;
/* Whether the first line of the paragraph had an anchor. */
char *primary_lead = NULL; char *primary_lead = NULL;
/* The leading part (quoting + indentation) of the first line /* The leading part (quoting + indentation) of the first line
* of the paragraph where the marked region begins. */ * of the paragraph where the marked region begins. */
@ -1872,7 +1872,6 @@ void do_justify(bool full_justify)
#ifndef NANO_TINY #ifndef NANO_TINY
add_undo(CUT, NULL); add_undo(CUT, NULL);
had_anchor = openfile->current->has_anchor;
#endif #endif
/* Do the equivalent of a marked cut into an empty cutbuffer. */ /* Do the equivalent of a marked cut into an empty cutbuffer. */
cutbuffer = NULL; cutbuffer = NULL;
@ -1942,7 +1941,7 @@ void do_justify(bool full_justify)
#ifndef NANO_TINY #ifndef NANO_TINY
add_undo(PASTE, NULL); add_undo(PASTE, NULL);
if (full_justify && !openfile->mark && !had_anchor) if (full_justify && !openfile->mark && !cutbuffer->has_anchor)
openfile->current->has_anchor = FALSE; openfile->current->has_anchor = FALSE;
#endif #endif
/* Do the equivalent of a paste of the justified text. */ /* Do the equivalent of a paste of the justified text. */