Skip to content

rustdoc: search should prioritize matching capitalization #119480

Description

@joshtriplett

It's good that rustdoc's search is case-insensitive, to make it easier for people to find what they're looking for. However, if the user types in capitalization that exactly matches (or more closely matches) a given type, rustdoc's search results should prioritize that type over things that don't match in case.

For example, https://doc.rust-lang.org/std/?search=Copy (note the capital C) should list std::marker::Copy at the top, not std::fs::copy.

Activity

  1. added
    T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
    on Dec 31, 2023
  2. added
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Dec 31, 2023
  3. added
    C-enhancementCategory: An issue proposing an enhancement or a PR with one.
    and removed
    needs-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
    on Jan 1, 2024
  4. camelid commented on Jan 8, 2024

    @camelid
    Member

    It might also make sense to make this based on whether there were capital letters in the user's input. Vim has a similar feature that can be enabled, where searching with all lowercase is case-insensitive, but mixed-case is sensitive. In rustdoc's case, we could do something similar, except make it case-preferenced rather than exclude non-matching capitalization altogether.

  5. tgross35 commented on Feb 28, 2024

    @tgross35
    Member

    The Vim style is smartcase (ripgrep has a --smart-case flag), which matches case insensitive unless there are any uppercase characters, in which case it does a case-sensitive match.

    However, that is better for when you have binary results (either it matches or it doesn't), giving precedence to exact-case matches is better when you can rank the results. This is what e.g. https://github.com/kentcdodds/match-sorter does.

    (I would have liked this for adding a PATH alias in #119748)

  6. lolbinarycat commented on Aug 22, 2024

    @lolbinarycat
    Contributor

    @rustbot claim

  7. added 5 commits that reference this issue on Aug 22, 2024
    7478e00
    74a2164
    4d66492
    f21a96f
    4c5e888
  8. added 3 commits that reference this issue on Aug 24, 2024
    17d312c
    616626a
    25a3c88
  9. added 2 commits that reference this issue on Aug 24, 2024
    11355f5
    8919cbe
  10. added a commit that references this issue on Aug 25, 2024
    093249a
  11. added a commit that references this issue on Aug 25, 2024
    d0745dd
  12. lolbinarycat commented on Sep 3, 2024

    @lolbinarycat
    Contributor

    reopening this because it's only fixed in the simplest case, if you use a full path it will not be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-rustdoc-searchArea: Rustdoc's search featureC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions