mirror of
git://git.sv.gnu.org/nano.git
synced 2024-11-26 06:39:43 +03:00
tweaks: move to a given line number more efficiently
Instead of starting always from the top of the buffer, start at the current line, as it is quite likely to be near the target line. (Since the previous commit we're assuming that openfile->current is always valid, so we might as well make use of this assumption.) Also, rename a parameter to make its meaning more explicit.
This commit is contained in:
parent
9410a55679
commit
d1e28417d5
11
src/search.c
11
src/search.c
@ -737,18 +737,15 @@ void ask_for_and_do_replacements(void)
|
||||
}
|
||||
|
||||
/* Go to the specified line and x position. */
|
||||
void goto_line_posx(ssize_t line, size_t pos_x)
|
||||
void goto_line_posx(ssize_t linenumber, size_t pos_x)
|
||||
{
|
||||
#ifdef ENABLE_COLOR
|
||||
if (line > openfile->edittop->lineno + editwinrows ||
|
||||
(ISSET(SOFTWRAP) && line > openfile->current->lineno))
|
||||
if (linenumber > openfile->edittop->lineno + editwinrows ||
|
||||
(ISSET(SOFTWRAP) && linenumber > openfile->current->lineno))
|
||||
recook |= perturbed;
|
||||
#endif
|
||||
|
||||
for (openfile->current = openfile->filetop; line > 1 &&
|
||||
openfile->current != openfile->filebot; line--)
|
||||
openfile->current = openfile->current->next;
|
||||
|
||||
openfile->current = line_from_number(linenumber);
|
||||
openfile->current_x = pos_x;
|
||||
openfile->placewewant = xplustabs();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user