nano-devel
[Top][All Lists]
Advanced

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

Re: [Nano-devel] [PATCH] Implement incremental search v4


From: Benno Schulenberg
Subject: Re: [Nano-devel] [PATCH] Implement incremental search v4
Date: Thu, 1 Feb 2018 16:14:21 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0


Op 01-02-18 om 01:04 schreef Marco Diego Aurélio Mesquita:
1) Run src/nano +1 NEWS, and type: ^W drastic <Enter>.  Then press
M-W.  It says it's the only occurrence.  Move the cursor one line
down and press M-W again.  Now it finds the second occurrence.

I'll investigate what causes this. Any hint?

I have no clue.  There do not seem to be any changes to do_search()
or findnextstr() that could cause this...

Ehm...  Check that.  This:

-   didfind = findnextstr(last_search, FALSE, JUSTFIND, NULL, TRUE,
-                               openfile->current, openfile->current_x);
+   didfind = findnextstr(last_search, FALSE, JUSTFIND, NULL, FALSE,
+                               openfile->current, openfile->current_x, TRUE)

You changed a TRUE to FALSE.  You probably made a mistake during
rebasing, because there were some minor changes in the search code
between 2.9.2 and 2.9.3.  With that mistake corrected, the M-W works
fine again.


By the way, there is no need to add a loop to the start of do_search().
I've changed the body to look like this, and things works fine:

    int i = search_init(FALSE, FALSE);

    if (i == -1) {  /* Cancelled, or some other exit reason. */
        highlight(FALSE, 0);
        if (ISSET(INCR_SEARCH)) {
            openfile->current = was_current;
            openfile->current_x = was_current_x;
            openfile->placewewant = xplustabs();
        }
        search_replace_abort();
    } else if (i == -2) /* Do a replace instead. */
        do_replace();
    else if (i == 1)    /* Toggled something. */
        do_search();

    if (i == 0 && !ISSET(INCR_SEARCH))
        go_looking();

Further, instead of adding a parameter to findnexstr(), it would be
better to add another possible value for the modus parameter.  It
could be called "INCREMENTAL", but that looks too much like the
INCREMENTAL_SEARCH flag, so I've called it "STEPWISE" here locally.

Any suggestion on how it should be called?

If you do things right, the inc_search_cb() function can be elided,
and you can use its suggested name for this one instead.

Benno



reply via email to

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