nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 703cebaaac439ea859bc6772e23b9a80c2c87d77
parent 4710b94cfb0d4dfef4ef65762a9d899169b3ea5f
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Wed, 29 Apr 2020 19:34:48 +0200

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.

Diffstat:
Msrc/text.c | 5+++++
1 file changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/text.c b/src/text.c @@ -1733,6 +1733,8 @@ 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. */ @@ -1870,6 +1872,7 @@ 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; @@ -1939,6 +1942,8 @@ void do_justify(bool full_justify) #ifndef NANO_TINY add_undo(PASTE, NULL); + if (full_justify && !openfile->mark && !had_anchor) + openfile->current->has_anchor = FALSE; #endif /* Do the equivalent of a paste of the justified text. */ ingraft_buffer(cutbuffer);