commit acb394aec0c165f827381165f9e541bf77501a54
parent 4223b83f7567e87af307d614a9b64659d949a32a
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date: Thu, 5 Jan 2017 21:38:00 -0600
screen: properly place the cursor after inserting a file
Instead of setting openfile->current_y (and wrongly so), just call
reset_cursor() to recompute current_y and place the cursor on that
line (if it is not offscreen).
Diffstat:
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/files.c b/src/files.c
@@ -1111,7 +1111,6 @@ void do_insertfile(void)
filestruct *edittop_save = openfile->edittop;
ssize_t was_current_lineno = openfile->current->lineno;
size_t was_current_x = openfile->current_x;
- ssize_t was_current_y = openfile->current_y;
bool current_was_at_top = FALSE;
#if !defined(NANO_TINY) || !defined(DISABLE_BROWSER)
functionptrtype func = func_from_key(&i);
@@ -1257,9 +1256,6 @@ void do_insertfile(void)
}
}
#endif
- /* Update the current y-coordinate to account for the
- * number of lines inserted. */
- openfile->current_y += was_current_y;
/* Unpartition the filestruct so that it contains all
* the text again. Note that we've replaced the
@@ -1282,6 +1278,10 @@ void do_insertfile(void)
openfile->current_x != was_current_x)
set_modified();
+ /* Update the cursor position to account for the number
+ * of lines inserted. */
+ reset_cursor();
+
refresh_needed = TRUE;
}