commit c346701d093daaa6938a8b52eba49260b853137f
parent 9a145d906f2fe2bcc5bc0274bf96dcf29a3ac386
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date: Thu, 13 Jul 2006 04:19:53 +0000
in do_insertfile(), if we don't insert a file into a new buffer,
properly update the x-coordinate to account for the number of characters
inserted on the current line
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@3786 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
Diffstat:
2 files changed, 20 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -83,6 +83,9 @@ CVS code -
- If we execute a command in a new buffer, move back to the
beginning of the first line of the buffer afterwards, for
consistency. (DLR)
+ - If we don't insert a file into a new buffer, properly update
+ the x-coordinate to account for the number of characters
+ inserted on the current line. (DLR)
get_full_path()
- Don't return NULL when the current directory doesn't exist, as
we can still recover from that. (DLR, found by Mike Frysinger)
diff --git a/src/files.c b/src/files.c
@@ -683,6 +683,7 @@ void do_insertfile(
char *ans = mallocstrcpy(NULL, "");
/* The last answer the user typed on the statusbar. */
filestruct *edittop_save = openfile->edittop;
+ size_t current_x_save = openfile->current_x;
ssize_t current_y_save = openfile->current_y;
bool at_edittop = FALSE;
/* Whether we're at the top of the edit window. */
@@ -845,20 +846,26 @@ void do_insertfile(
{
filestruct *top_save = openfile->fileage;
- /* If we didn't insert into a new buffer, and we were at
- * the top of the edit window before, set the saved
- * value of edittop to the new top of the edit window,
- * and update the current y-coordinate to account for
- * the number of lines inserted. */
+ /* If we were at the top of the edit window before, set
+ * the saved value of edittop to the new top of the edit
+ * window. */
if (at_edittop)
edittop_save = openfile->fileage;
+
+ /* Update the current x-coordinate to account for the
+ * number of characters inserted on the current line. */
+ openfile->current_x = strlen(openfile->filebot->data);
+ if (openfile->fileage == openfile->filebot)
+ openfile->current_x += current_x_save;
+
+ /* Update the current y-coordinate to account for the
+ * number of lines inserted. */
openfile->current_y += current_y_save;
- /* If we didn't insert into a new buffer, unpartition
- * the filestruct so that it contains all the text
- * again. Note that we've replaced the non-text
- * originally in the partition with the text in the
- * inserted file/executed command output. */
+ /* Unpartition the filestruct so that it contains all
+ * the text again. Note that we've replaced the
+ * non-text originally in the partition with the text in
+ * the inserted file/executed command output. */
unpartition_filestruct(&filepart);
/* Renumber starting with the beginning line of the old