> Date: Fri, 18 Aug 2000 02:08:03 +0200
> From: Josip Rodin <[EMAIL PROTECTED]>
>
> ----- Forwarded message from "H. Nanosecond" <[EMAIL PROTECTED]> -----
>
> Subject: Bug#68936: info and repeated items
> Reply-To: "H. Nanosecond" <[EMAIL PROTECTED]>,
> [EMAIL PROTECTED]
> X-Debian-PR-Package: texinfo
> Date: Fri, 11 Aug 2000 03:30:58 -0400 (EDT)
> To: [EMAIL PROTECTED]
> From: "H. Nanosecond" <[EMAIL PROTECTED]>
>
> Package: texinfo
> Version: 4.0-4
>
> Hello,
>
> In the info program selecting a link doesn't work if two items of the
> same name but different nodes are listed. Those listed later will go to
> the previously listed node.
I believe that the following patch solves this problem in a reasonable
way. Please try it.
2000-08-23 Eli Zaretskii <[EMAIL PROTECTED]>
* info/session.c (info_menu_or_ref_item): If the user have chosen
menu item or xref that's identical to defentry's label, use
defentry instead of looking for its label. Otherwise, select the
entry whose position is the closest to the window's point, in
case there's more than a single entry with that label.
--- info/session.c~1 Sat Sep 25 18:10:14 1999
+++ info/session.c Wed Aug 23 19:18:54 2000
@@ -2139,8 +2139,43 @@ info_menu_or_ref_item (window, count, ke
if (line)
{
- /* Find the selected label in the references. */
- entry = info_get_labeled_reference (line, menu);
+ /* It is possible that the references have more than a single
+ entry with the same label, and also LINE is down-cased, which
+ complicates matters even more. Try to be as accurate as we
+ can: if they've chosen the default, use defentry directly. */
+ if (defentry && strcmp (line, defentry->label) == 0)
+ entry = defentry;
+ else
+ /* Find the selected label in the references. If there are
+ more than one label which matches, find the one that's
+ closest to point. */
+ {
+ register int i;
+ int best = -1, min_dist = window->node->nodelen;
+ REFERENCE *ref;
+
+ for (i = 0; menu && (ref = menu[i]); i++)
+ {
+ /* Need to use strcasecmp because LINE is downcased
+ inside info_read_completing_in_echo_area. */
+ if (strcasecmp (line, ref->label) == 0)
+ {
+ /* ref->end is more accurate estimate of position
+ for menus than ref->start. Go figure. */
+ int dist = abs (window->point - ref->end);
+
+ if (dist < min_dist)
+ {
+ min_dist = dist;
+ best = i;
+ }
+ }
+ }
+ if (best != -1)
+ entry = menu[best];
+ else
+ entry = (REFERENCE *)NULL;
+ }
if (!entry && defentry)
info_error (_("The reference disappeared! (%s)."), line);