fix off-by-one problems with COLUMN; it should be zero-based

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2524 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
David Lawrence Ramsey 2005-05-17 18:29:05 +00:00
parent 650b39c43d
commit f83e5e2b13
2 changed files with 10 additions and 8 deletions

View File

@ -4496,7 +4496,7 @@ int main(int argc, char **argv)
display_main_list(); display_main_list();
if (startline > 1 || startcol > 1) if (startline > 1 || startcol > 1)
do_gotolinecolumn(startline, startcol, FALSE, FALSE, FALSE); do_gotolinecolumn(startline, startcol - 1, FALSE, FALSE, FALSE);
#ifndef NANO_SMALL #ifndef NANO_SMALL
/* Return here after a SIGWINCH. */ /* Return here after a SIGWINCH. */

View File

@ -255,7 +255,7 @@ int search_init(bool replacing, bool use_answer)
#ifndef NANO_SMALL #ifndef NANO_SMALL
search_history.current = search_history.next; search_history.current = search_history.next;
#endif #endif
do_gotolinecolumn(1, 1, TRUE, TRUE, FALSE); do_gotolinecolumn(1, 0, TRUE, TRUE, FALSE);
/* Put answer up on the statusbar and /* Put answer up on the statusbar and
* fall through. */ * fall through. */
default: default:
@ -998,9 +998,11 @@ void do_gotolinecolumn(int line, ssize_t column, bool use_answer, bool
} }
/* Do a bounds check. Display a warning on an out-of-bounds /* Do a bounds check. Display a warning on an out-of-bounds
* line number only if we hit Enter at the statusbar prompt. */ * line number (which is one-based) or an out-of-bounds column
* number (which is zero-based) only if we hit Enter at the
* statusbar prompt. */
if (!parse_line_column(answer, &line, &column) || line < 1 || if (!parse_line_column(answer, &line, &column) || line < 1 ||
column < 1) { column < 0) {
if (i == 0) if (i == 0)
statusbar(_("Come on, be reasonable")); statusbar(_("Come on, be reasonable"));
display_main_list(); display_main_list();
@ -1010,8 +1012,8 @@ void do_gotolinecolumn(int line, ssize_t column, bool use_answer, bool
if (line < 1) if (line < 1)
line = 1; line = 1;
if (column < 1) if (column < 0)
column = 1; column = 0;
} }
if (current->lineno > line) { if (current->lineno > line) {
@ -1024,8 +1026,8 @@ void do_gotolinecolumn(int line, ssize_t column, bool use_answer, bool
; ;
} }
current_x = actual_x(current->data, column - 1); current_x = actual_x(current->data, column);
placewewant = column - 1; placewewant = column;
/* If save_pos is TRUE, don't change the cursor position when /* If save_pos is TRUE, don't change the cursor position when
* updating the edit window. */ * updating the edit window. */