history: do not forget anchors when line number is given on command line
When a line number is given on the command line, the position-history
file needs to be read first, because it might contain saved anchors.
(Before placing the cursor on the given line, or searching for a given
string, the current position now needs to be set back to top-of-file,
as otherwise the saved column position is likely to be inherited, or
the search will start from the inherited position.)
This fixes https://savannah.gnu.org/bugs/?67272.
Bug existed since version 8.5, commit 60e2f2ba,
since the saving of anchors was introduced.
This commit is contained in:
16
src/nano.c
16
src/nano.c
@@ -2580,11 +2580,21 @@ int main(int argc, char **argv)
|
||||
continue;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_HISTORIES
|
||||
if (ISSET(POSITIONLOG) && openfile->filename[0] != '\0')
|
||||
restore_cursor_position_if_any();
|
||||
#endif
|
||||
|
||||
/* If a position was given on the command line, go there. */
|
||||
if (givenline != 0 || givencol != 0)
|
||||
if (givenline != 0 || givencol != 0) {
|
||||
openfile->current = openfile->filetop;
|
||||
openfile->placewewant = 0;
|
||||
goto_line_and_column(givenline, givencol, FALSE, FALSE);
|
||||
}
|
||||
#ifndef NANO_TINY
|
||||
else if (searchstring != NULL) {
|
||||
openfile->current = openfile->filetop;
|
||||
openfile->current_x = 0;
|
||||
if (ISSET(USE_REGEXP))
|
||||
regexp_init(searchstring);
|
||||
if (!findnextstr(searchstring, FALSE, JUSTFIND, NULL,
|
||||
@@ -2600,10 +2610,6 @@ int main(int argc, char **argv)
|
||||
last_search = searchstring;
|
||||
searchstring = NULL;
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_HISTORIES
|
||||
else if (ISSET(POSITIONLOG) && openfile->filename[0] != '\0')
|
||||
restore_cursor_position_if_any();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user