nano

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

commit e1c6ae7cf355f50b57b546b8688b8be2643570d8
parent bb7a9fe7d2bf8f80a7c64803cba951f471bb0099
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Tue, 19 Mar 2024 16:24:48 +0100

justify: keep the cursor at the original end of a marked region

When justifying a region that was marked backwards, the cursor
should stay at the beginning of this region.  The old logic was
faulty because mark_is_before_cursor() does not give the correct
result *after* the justification has been done: for some reason
the mark ends up always before the cursor.

Bug existed since version 5.2, commit 0f8423eb,
which mistakenly removed the auxiliary variable.  :/

Diffstat:
Msrc/text.c | 3++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/text.c b/src/text.c @@ -1767,6 +1767,7 @@ void justify_text(bool whole_buffer) /* The length of that later lead. */ ssize_t was_the_linenumber = openfile->current->lineno; /* The line to return to after a full justification. */ + bool marked_backward = (openfile->mark && !mark_is_before_cursor()); /* TRANSLATORS: This one goes with Undid/Redid messages. */ add_undo(COUPLE_BEGIN, N_("justification")); @@ -1976,7 +1977,7 @@ void justify_text(bool whole_buffer) update_undo(PASTE); /* After justifying a backward-marked text, swap mark and cursor. */ - if (openfile->mark && !mark_is_before_cursor()) { + if (marked_backward) { linestruct *bottom = openfile->current; size_t bottom_x = openfile->current_x;