commit 11f099e1daa2293be713253fe3b465117a3ea406
parent 703cebaaac439ea859bc6772e23b9a80c2c87d77
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 30 Apr 2020 16:02:27 +0200
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.
Diffstat:
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/text.c b/src/text.c
@@ -1564,7 +1564,9 @@ void concat_paragraph(linestruct *line, size_t count)
line->data = charealloc(line->data,
line_len + next_line_len - next_lead_len + 1);
strcat(line->data, next_line->data + next_lead_len);
-
+#ifndef NANO_TINY
+ line->has_anchor |= next_line->has_anchor;
+#endif
unlink_node(next_line);
count--;
}
@@ -1733,8 +1735,6 @@ void do_justify(bool full_justify)
/* Whether the mark (if any) is before the cursor. */
bool before_eol = FALSE;
/* 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;
/* The leading part (quoting + indentation) of the first line
* of the paragraph where the marked region begins. */
@@ -1872,7 +1872,6 @@ void do_justify(bool full_justify)
#ifndef NANO_TINY
add_undo(CUT, NULL);
- had_anchor = openfile->current->has_anchor;
#endif
/* Do the equivalent of a marked cut into an empty cutbuffer. */
cutbuffer = NULL;
@@ -1942,7 +1941,7 @@ void do_justify(bool full_justify)
#ifndef NANO_TINY
add_undo(PASTE, NULL);
- if (full_justify && !openfile->mark && !had_anchor)
+ if (full_justify && !openfile->mark && !cutbuffer->has_anchor)
openfile->current->has_anchor = FALSE;
#endif
/* Do the equivalent of a paste of the justified text. */