[PATCH 2/3] moving: preserve horizontal position when jumping to top or bottom row

Benno Schulenberg <[email protected]>
Newsgroups gmane.editors.nano.devel
Message-ID <[email protected]>
---
 src/move.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/src/move.c b/src/move.c
index fe171bfc..0cc2d769 100644
--- a/src/move.c
+++ b/src/move.c
@@ -180,8 +180,14 @@ void do_page_down(void)
 /* Place the cursor on the first row in the viewport. */
 void to_top_row(void)
 {
+	size_t leftedge, offset;
+
+	get_edge_and_target(&leftedge, &offset);
+
 	openfile->current = openfile->edittop;
-	openfile->current_x = actual_x(openfile->current->data, openfile->firstcolumn);
+	leftedge = openfile->firstcolumn;
+
+	set_proper_index_and_pww(&leftedge, offset, FALSE);
 
 	place_the_cursor();
 }
@@ -189,12 +195,15 @@ void to_top_row(void)
 /* Place the cursor on the last row in the viewport, when possible. */
 void to_bottom_row(void)
 {
-	size_t leftedge = openfile->firstcolumn;
+	size_t leftedge, offset;
+
+	get_edge_and_target(&leftedge, &offset);
 
 	openfile->current = openfile->edittop;
+	leftedge = openfile->firstcolumn;
 
 	go_forward_chunks(editwinrows - 1, &openfile->current, &leftedge);
-	openfile->current_x = actual_x(openfile->current->data, leftedge);
+	set_proper_index_and_pww(&leftedge, offset, TRUE);
 
 	place_the_cursor();
 }
-- 
2.42.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.