nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Benno Schulenberg
Subject: [PATCH 2/3] moving: preserve horizontal position when jumping to top or bottom row
Date: Mon, 25 Mar 2024 11:07:09 +0100

---
 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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]