- 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)
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. */
{
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