#169 Show Matching Range Bugfix

Eddy De Greef
Program (402)
Tom Heathcote

This patch fixes a minor problem with the Show
Matching feature when it is used in Range mode.

NEdit 5.3RC1 does not normally(*) apply the "Show
Matching" highlighting if the matching delimiter is
not visible in the window (it saves time by
constraining the search for the matching delimiter
to the visible text).

(*) It does search the whole text when in split-
window mode.

This makes perfect sense in "Delimiter" mode
(which was originally the only way that Show
Matching operated) but does not make much sense
in Range mode.

The patch changes this behaviour, so that when
Show Matching is set to Range, NEdit will always
highlight the visible part of the range between the

This patch is for 5.3RC1. This patch has been
tested on Linux, Solaris, IRIX, AIX and HP-UX.

This change does mean that NEdit could potentially
search the whole buffer for a matching delimiter,
which *could* slow it down when it passes a
delimiter... but:

1. NEdit already behaved in exactly this way when it
was in split-window mode, so it can't have been
that much of a problem.

2. In most cases either the end of the text buffer
will be hit very soon (adding new text at or near the
end of a file) or a matching delimiter will be found
quite soon.

3. The change *only* affects Range mode. If you are
using Delimiter mode it works the same as before.

4. I have tested this in the worst case scenario and
the slowdown is quite acceptable:

I went to the slowest machine in the building, an
HP 9000/712 workstation dating from late 1993
which has a 60MHz PA-RISC processor; I opened
the longest C++ file I could find (just over 10,000
lines), and I added some unmatched opening
braces at the start of the file (so that NEdit would
have to search the entire text buffer before
deciding that there was no matching delimiter).

There was some slowdown when in Range mode,
but it was only noticable when I held down the "{"
key and entered a whole series of {'s, or when I held
down the cursor key and moved backwards or
forwards through the long series of {'s.

When entering normal code or text, the slowdown
was barely noticable and certainly not intrusive.


  • Nathan Gray
    Nathan Gray

    Logged In: YES

    You don't really need to find the matching delimiter when using
    range mode. If the delimiter isn't found you can just highlight to
    the top/bottom of the screen. I've got a patch that does this -- I'll
    send it to the develop list since I can't attach a file here.

  • Eddy De Greef
    Eddy De Greef

    • status: open --> open-fixed
  • Eddy De Greef
    Eddy De Greef

    Logged In: YES

    The fix is in CVS. Thanks.
    (It would have gotten more attention if it was filed as a
    bug from the start.)

  • Thorsten Haude
    Thorsten Haude

    • priority: 5 --> 1
  • Eddy De Greef
    Eddy De Greef

    • labels: --> Program
    • milestone: --> release
    • assigned_to: nobody --> edg
    • status: open-fixed --> closed-fixed
  • Eddy De Greef
    Eddy De Greef

    Logged In: YES

    I thought I closed this one.