nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Minor improvements to anchor code


From: Benno Schulenberg
Subject: Re: [PATCH] Minor improvements to anchor code
Date: Wed, 15 Apr 2020 11:59:30 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1

Op 14-04-2020 om 18:50 schreef Marco Diego Aurélio Mesquita:
> Please consider attached patches as minor improvements to current code
> wrt anchor and line jumping.

Sorry, I do not find them improvements.

> +     do {
> +             line =  forward ?
> +                     ((line->next) ? line->next : openfile->filetop):
> +                     ((line->prev) ? line->prev : openfile->filebot);
> +     } while (!line->has_anchor && line != openfile->current);

This heaps too many conditions together.

> -             edit_redraw(was_current, CENTERING);
> +             edit_redraw(openfile->current, CENTERING);

This is wrong.  To see the problem, apply the patch and run:

    src/nano --line +6,22 README

Then type: M-Ins  M-A  <Down> <Down>
See that "was" to "editor" is highlighted.
Now type M-PgUp.  See how line 7 mistakenly stays highlighted.
Type ^L.  Only "The nano project" is now highlighted, as it should be.

> +/* Goes to specified line and position */
> +void go_to_line(const linestruct *line, size_t line_x)
> +{
> +     openfile->current = line;
> +     openfile->current_x = line_x;
> +}

I don't like functions that consist of just one or two lines.  Also,
the change does not make things clearer, and most likely it makes the
binary bigger: pushing the two values onto the stack and then making
the call probably takes more bytes than just moving the two values
into place directly.

Benno

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]