anchor: do not let a full justification transfer an anchor to the top

This fixes https://savannah.gnu.org/bugs/?58272.

Bug existed since commit 732cf887 from one month ago.  That code
causes an anchor to persist at the point where lines are removed.
master
Benno Schulenberg 2020-04-29 19:34:48 +02:00
parent 4710b94cfb
commit 703cebaaac
1 changed files with 5 additions and 0 deletions

View File

@ -1733,6 +1733,8 @@ 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. */
@ -1870,6 +1872,7 @@ 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;
@ -1939,6 +1942,8 @@ 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)
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. */
ingraft_buffer(cutbuffer); ingraft_buffer(cutbuffer);