Commit ea19c736 authored by Robert Siemborski's avatar Robert Siemborski
Browse files

fix for the totsize / cut bug

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@16 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 11 additions and 10 deletions
+11 -10
...@@ -32,3 +32,8 @@ ...@@ -32,3 +32,8 @@
until a pageup/down occurs (22). until a pageup/down occurs (22).
- edit_refresh() and update_line() (and related functions), have - edit_refresh() and update_line() (and related functions), have
trouble when a tab is the character that is the boundry at COLS (23) trouble when a tab is the character that is the boundry at COLS (23)
- there is an off-by-one error in keeping track of totsize. It is caused
by the fact that we count the newline at the end when we read in a file
but we do not, in fact, display this newline. This should go away
implicitly when the "Magic Line" returns, but it is noted here for
documentation's sake. (24)
...@@ -44,7 +44,7 @@ void add_to_cutbuffer(filestruct * inptr) ...@@ -44,7 +44,7 @@ void add_to_cutbuffer(filestruct * inptr)
inptr->data); inptr->data);
#endif #endif
totsize -= strlen(inptr->data) + 1; totsize -= strlen(inptr->data);
tmp = cutbuffer; tmp = cutbuffer;
if (cutbuffer == NULL) { if (cutbuffer == NULL) {
cutbuffer = inptr; cutbuffer = inptr;
...@@ -82,6 +82,7 @@ void cut_marked_segment(filestruct * top, int top_x, filestruct * bot, ...@@ -82,6 +82,7 @@ void cut_marked_segment(filestruct * top, int top_x, filestruct * bot,
next = tmp->next; next = tmp->next;
add_to_cutbuffer(tmp); add_to_cutbuffer(tmp);
totlines--; totlines--;
totsize--; /* newline (add_to_cutbuffer doesn't count newlines) */
tmp = next; tmp = next;
} }
while (next != bot && next != NULL); while (next != bot && next != NULL);
...@@ -101,7 +102,8 @@ void cut_marked_segment(filestruct * top, int top_x, filestruct * bot, ...@@ -101,7 +102,8 @@ void cut_marked_segment(filestruct * top, int top_x, filestruct * bot,
next = bot->next; next = bot->next;
/* We explicitly don't decrement totlines here because we don't snarf /* We explicitly don't decrement totlines here because we don't snarf
* up a newline when we're grabbing the last line of the mark */ * up a newline when we're grabbing the last line of the mark. For
* the same reason we don't do an extra totsize decrement */
add_to_cutbuffer(bot); add_to_cutbuffer(bot);
top->next = next; top->next = next;
...@@ -183,7 +185,7 @@ int do_cut_text(void) ...@@ -183,7 +185,7 @@ int do_cut_text(void)
UNSET(MARK_ISSET); UNSET(MARK_ISSET);
marked_cut = 1; marked_cut = 1;
set_modified(); set_modified();
edit_update_top(edittop); edit_update(current);
return 1; return 1;
#else #else
if (0) { if (0) {
...@@ -201,10 +203,9 @@ int do_cut_text(void) ...@@ -201,10 +203,9 @@ int do_cut_text(void)
current = fileptr; current = fileptr;
} else { } else {
add_to_cutbuffer(fileptr); add_to_cutbuffer(fileptr);
totlines--;
fileage = make_new_node(NULL); fileage = make_new_node(NULL);
fileage->data = nmalloc(1); fileage->data = nmalloc(1);
strcpy(fileage->data, ""); fileage->data[0] = '\0';
current = fileage; current = fileage;
} }
} else { } else {
......
...@@ -1066,11 +1066,6 @@ int do_cursorpos(void) ...@@ -1066,11 +1066,6 @@ int do_cursorpos(void)
for (fileptr = current->next; fileptr != NULL; fileptr = fileptr->next) for (fileptr = current->next; fileptr != NULL; fileptr = fileptr->next)
tot += strlen(fileptr->data) + 1; tot += strlen(fileptr->data) + 1;
/* FIXME - This is gardly elegant */
/* if (current == fileage && strlen(current->data) == 0)
i = 0;
*/
if (totlines > 0) if (totlines > 0)
linepct = 100 * current->lineno / totlines; linepct = 100 * current->lineno / totlines;
else else
......
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