diff --git a/ChangeLog b/ChangeLog
index 23020d65af8cda9a230c2d8a028baa6135bf684d..65fdadf0ec88f1c4140079525e38a29651e65e47 100644
--- 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
index cf4234c9dc5dae2999635c01e9cf232f1c83dbb9..d4511ddb05be04bef19f0a29f8032dced9ee4bda 100644
--- 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