commit 803ea0d7a095450835e8151f326177135ab518bc
parent 9b014876cd68f9f4df297cf16739e72431ff6904
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Thu, 24 Mar 2022 12:40:28 +0100
justify: stay at the same line number when doing a full justification
The same line number may not be the same position in the text, but
it will be approximately -- and it is certainly better than leaving
the cursor at the end of the buffer.
This fulfills https://savannah.gnu.org/bugs/?61175.
Diffstat:
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/text.c b/src/text.c
@@ -1761,6 +1761,8 @@ void justify_text(bool whole_buffer)
/* The leading part for lines after the first one. */
size_t secondary_len = 0;
/* The length of that later lead. */
+ ssize_t was_the_linenumber = openfile->current->lineno;
+ /* The line to return to after a full justification. */
/* TRANSLATORS: This one goes with Undid/Redid messages. */
add_undo(COUPLE_BEGIN, N_("justification"));
@@ -1977,7 +1979,8 @@ void justify_text(bool whole_buffer)
openfile->current_x = openfile->mark_x;
openfile->mark = bottom;
openfile->mark_x = bottom_x;
- }
+ } else if (whole_buffer && !openfile->mark)
+ goto_line_posx(was_the_linenumber, 0);
add_undo(COUPLE_END, N_("justification"));