fix for the totsize / cut bug
git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@16 35c25a1d-7b9e-4130-9fde-d3aeb78583b8master
parent
ab4295b80c
commit
ea19c7369f
5
BUGS
5
BUGS
|
@ -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)
|
||||||
|
|
11
cut.c
11
cut.c
|
@ -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,
|
||||||
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,
|
||||||
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)
|
||||||
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)
|
||||||
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 {
|
||||||
|
|
5
winio.c
5
winio.c
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue