replacing: don't let placewewant influence the placement of the cursor

When spotlighting the string to be replaced, placewewant isn't valid,
so tell place_the_cursor() to ignore its value to avoid the cursor
getting mistakenly placed at the beginning of the next row.

This fixes https://savannah.gnu.org/bugs/?50997.
Reported-by: David Lawrence Ramsey <pooka109@gmail.com>
master
Benno Schulenberg 2017-05-11 22:24:39 +02:00
parent 08fd5b349b
commit 28beb3f9c5
6 changed files with 14 additions and 13 deletions

View File

@ -292,7 +292,7 @@ void do_uncut_text(void)
set_modified(); set_modified();
/* Update current_y to account for the inserted lines. */ /* Update current_y to account for the inserted lines. */
place_the_cursor(); place_the_cursor(TRUE);
refresh_needed = TRUE; refresh_needed = TRUE;

View File

@ -1198,7 +1198,7 @@ void do_insertfile(void)
set_modified(); set_modified();
/* Update current_y to account for inserted lines. */ /* Update current_y to account for inserted lines. */
place_the_cursor(); place_the_cursor(TRUE);
refresh_needed = TRUE; refresh_needed = TRUE;
} }

View File

@ -2659,7 +2659,7 @@ int main(int argc, char **argv)
/* Refresh just the cursor position or the entire edit window. */ /* Refresh just the cursor position or the entire edit window. */
if (!refresh_needed) { if (!refresh_needed) {
place_the_cursor(); place_the_cursor(TRUE);
wnoutrefresh(edit); wnoutrefresh(edit);
} else } else
edit_refresh(); edit_refresh();

View File

@ -650,7 +650,7 @@ void warn_and_shortly_pause(const char *msg);
void statusline(message_type importance, const char *msg, ...); void statusline(message_type importance, const char *msg, ...);
void bottombars(int menu); void bottombars(int menu);
void onekey(const char *keystroke, const char *desc, int length); void onekey(const char *keystroke, const char *desc, int length);
void place_the_cursor(void); void place_the_cursor(bool forreal);
void edit_draw(filestruct *fileptr, const char *converted, void edit_draw(filestruct *fileptr, const char *converted,
int line, size_t from_col); int line, size_t from_col);
int update_line(filestruct *fileptr, size_t index); int update_line(filestruct *fileptr, size_t index);

View File

@ -2439,7 +2439,7 @@ void do_justify(bool full_justify)
do { do {
#endif #endif
statusbar(_("Can now UnJustify!")); statusbar(_("Can now UnJustify!"));
place_the_cursor(); place_the_cursor(TRUE);
curs_set(1); curs_set(1);
kbinput = do_input(FALSE); kbinput = do_input(FALSE);
#ifndef NANO_TINY #ifndef NANO_TINY
@ -3311,7 +3311,7 @@ void do_linter(void)
} }
/* Place and show the cursor to indicate the affected line. */ /* Place and show the cursor to indicate the affected line. */
place_the_cursor(); place_the_cursor(TRUE);
wnoutrefresh(edit); wnoutrefresh(edit);
curs_set(1); curs_set(1);
@ -3558,7 +3558,7 @@ void do_verbatim_input(void)
/* TRANSLATORS: This is displayed when the next keystroke will be /* TRANSLATORS: This is displayed when the next keystroke will be
* inserted verbatim. */ * inserted verbatim. */
statusbar(_("Verbatim Input")); statusbar(_("Verbatim Input"));
place_the_cursor(); place_the_cursor(TRUE);
curs_set(1); curs_set(1);
/* Read in all the verbatim characters. */ /* Read in all the verbatim characters. */

View File

@ -1235,7 +1235,7 @@ int parse_escape_sequence(WINDOW *win, int kbinput)
suppress_cursorpos = FALSE; suppress_cursorpos = FALSE;
lastmessage = HUSH; lastmessage = HUSH;
if (currmenu == MMAIN) { if (currmenu == MMAIN) {
place_the_cursor(); place_the_cursor(TRUE);
curs_set(1); curs_set(1);
} }
} }
@ -2271,7 +2271,7 @@ void onekey(const char *keystroke, const char *desc, int length)
/* Redetermine current_y from the position of current relative to edittop, /* Redetermine current_y from the position of current relative to edittop,
* and put the cursor in the edit window at (current_y, "current_x"). */ * and put the cursor in the edit window at (current_y, "current_x"). */
void place_the_cursor(void) void place_the_cursor(bool forreal)
{ {
ssize_t row = 0; ssize_t row = 0;
size_t col, xpt = xplustabs(); size_t col, xpt = xplustabs();
@ -2293,7 +2293,7 @@ void place_the_cursor(void)
col = xpt % editwincols; col = xpt % editwincols;
/* If the cursor ought to be in column zero, nudge it there. */ /* If the cursor ought to be in column zero, nudge it there. */
if (openfile->placewewant % editwincols == 0 && col != 0) { if (forreal && openfile->placewewant % editwincols == 0 && col != 0) {
row++; row++;
col = 0; col = 0;
} }
@ -2307,7 +2307,8 @@ void place_the_cursor(void)
if (row < editwinrows) if (row < editwinrows)
wmove(edit, row, margin + col); wmove(edit, row, margin + col);
openfile->current_y = row; if (forreal)
openfile->current_y = row;
} }
/* edit_draw() takes care of the job of actually painting a line into /* edit_draw() takes care of the job of actually painting a line into
@ -3089,7 +3090,7 @@ void edit_refresh(void)
while (row < editwinrows) while (row < editwinrows)
blank_row(edit, row++, 0, COLS); blank_row(edit, row++, 0, COLS);
place_the_cursor(); place_the_cursor(TRUE);
wnoutrefresh(edit); wnoutrefresh(edit);
refresh_needed = FALSE; refresh_needed = FALSE;
@ -3248,7 +3249,7 @@ void spotlight(bool active, const char *word)
room--; room--;
} }
place_the_cursor(); place_the_cursor(FALSE);
if (active) if (active)
wattron(edit, hilite_attribute); wattron(edit, hilite_attribute);