Commit c346701d authored by David Lawrence Ramsey's avatar David Lawrence Ramsey
Browse files

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
parent 9a145d90
Showing with 20 additions and 10 deletions
+20 -10
...@@ -83,6 +83,9 @@ CVS code - ...@@ -83,6 +83,9 @@ CVS code -
- If we execute a command in a new buffer, move back to the - If we execute a command in a new buffer, move back to the
beginning of the first line of the buffer afterwards, for beginning of the first line of the buffer afterwards, for
consistency. (DLR) 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() get_full_path()
- Don't return NULL when the current directory doesn't exist, as - Don't return NULL when the current directory doesn't exist, as
we can still recover from that. (DLR, found by Mike Frysinger) we can still recover from that. (DLR, found by Mike Frysinger)
......
...@@ -683,6 +683,7 @@ void do_insertfile( ...@@ -683,6 +683,7 @@ void do_insertfile(
char *ans = mallocstrcpy(NULL, ""); char *ans = mallocstrcpy(NULL, "");
/* The last answer the user typed on the statusbar. */ /* The last answer the user typed on the statusbar. */
filestruct *edittop_save = openfile->edittop; filestruct *edittop_save = openfile->edittop;
size_t current_x_save = openfile->current_x;
ssize_t current_y_save = openfile->current_y; ssize_t current_y_save = openfile->current_y;
bool at_edittop = FALSE; bool at_edittop = FALSE;
/* Whether we're at the top of the edit window. */ /* Whether we're at the top of the edit window. */
...@@ -845,20 +846,26 @@ void do_insertfile( ...@@ -845,20 +846,26 @@ void do_insertfile(
{ {
filestruct *top_save = openfile->fileage; filestruct *top_save = openfile->fileage;
/* If we didn't insert into a new buffer, and we were at /* If we were at the top of the edit window before, set
* the top of the edit window before, set the saved * the saved value of edittop to the new top of the edit
* value of edittop to the new top of the edit window, * window. */
* and update the current y-coordinate to account for
* the number of lines inserted. */
if (at_edittop) if (at_edittop)
edittop_save = openfile->fileage; 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; openfile->current_y += current_y_save;
/* If we didn't insert into a new buffer, unpartition /* Unpartition the filestruct so that it contains all
* the filestruct so that it contains all the text * the text again. Note that we've replaced the
* again. Note that we've replaced the non-text * non-text originally in the partition with the text in
* originally in the partition with the text in the * the inserted file/executed command output. */
* inserted file/executed command output. */
unpartition_filestruct(&filepart); unpartition_filestruct(&filepart);
/* Renumber starting with the beginning line of the old /* Renumber starting with the beginning line of the old
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment