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();
/* Update current_y to account for the inserted lines. */
place_the_cursor();
place_the_cursor(TRUE);
refresh_needed = TRUE;

View File

@ -1198,7 +1198,7 @@ void do_insertfile(void)
set_modified();
/* Update current_y to account for inserted lines. */
place_the_cursor();
place_the_cursor(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. */
if (!refresh_needed) {
place_the_cursor();
place_the_cursor(TRUE);
wnoutrefresh(edit);
} else
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 bottombars(int menu);
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,
int line, size_t from_col);
int update_line(filestruct *fileptr, size_t index);

View File

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

View File

@ -1235,7 +1235,7 @@ int parse_escape_sequence(WINDOW *win, int kbinput)
suppress_cursorpos = FALSE;
lastmessage = HUSH;
if (currmenu == MMAIN) {
place_the_cursor();
place_the_cursor(TRUE);
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,
* 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;
size_t col, xpt = xplustabs();
@ -2293,7 +2293,7 @@ void place_the_cursor(void)
col = xpt % editwincols;
/* 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++;
col = 0;
}
@ -2307,6 +2307,7 @@ void place_the_cursor(void)
if (row < editwinrows)
wmove(edit, row, margin + col);
if (forreal)
openfile->current_y = row;
}
@ -3089,7 +3090,7 @@ void edit_refresh(void)
while (row < editwinrows)
blank_row(edit, row++, 0, COLS);
place_the_cursor();
place_the_cursor(TRUE);
wnoutrefresh(edit);
refresh_needed = FALSE;
@ -3248,7 +3249,7 @@ void spotlight(bool active, const char *word)
room--;
}
place_the_cursor();
place_the_cursor(FALSE);
if (active)
wattron(edit, hilite_attribute);