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
This commit is contained in:
David Lawrence Ramsey
2006-07-13 04:19:53 +00:00
parent 9a145d906f
commit c346701d09
2 changed files with 20 additions and 10 deletions

View File

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