Skip to content

rustdoc: search should prioritize matching capitalization #119480

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
joshtriplett opened this issue Dec 31, 2023 · 4 comments · Fixed by #129430
Open

rustdoc: search should prioritize matching capitalization #119480

joshtriplett opened this issue Dec 31, 2023 · 4 comments · Fixed by #129430
Assignees
Labels
A-rustdoc-search Area: Rustdoc's search feature C-enhancement Category: An issue proposing an enhancement or a PR with one. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@joshtriplett
Copy link
Member

joshtriplett commented Dec 31, 2023

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.

@joshtriplett joshtriplett added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-rustdoc-search Area: Rustdoc's search feature labels Dec 31, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 31, 2023
@fmease fmease added C-enhancement Category: An issue proposing an enhancement or a PR with one. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jan 1, 2024
@camelid
Copy link
Member

camelid commented Jan 8, 2024

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.

@tgross35
Copy link
Contributor

tgross35 commented Feb 28, 2024

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)

@lolbinarycat
Copy link
Contributor

@rustbot claim

lolbinarycat added a commit to lolbinarycat/rust that referenced this issue Aug 22, 2024
lolbinarycat added a commit to lolbinarycat/rust that referenced this issue Aug 22, 2024
lolbinarycat added a commit to lolbinarycat/rust that referenced this issue Aug 22, 2024
lolbinarycat added a commit to lolbinarycat/rust that referenced this issue Aug 22, 2024
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Aug 24, 2024
…case, r=notriddle

rustdoc: show exact case-sensitive matches first

fixes rust-lang#119480
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Aug 24, 2024
…case, r=notriddle

rustdoc: show exact case-sensitive matches first

fixes rust-lang#119480
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Aug 24, 2024
…case, r=notriddle

rustdoc: show exact case-sensitive matches first

fixes rust-lang#119480
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 24, 2024
…case, r=notriddle

rustdoc: show exact case-sensitive matches first

fixes rust-lang#119480
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Aug 24, 2024
…case, r=notriddle

rustdoc: show exact case-sensitive matches first

fixes rust-lang#119480
tgross35 added a commit to tgross35/rust that referenced this issue Aug 25, 2024
…case, r=notriddle

rustdoc: show exact case-sensitive matches first

fixes rust-lang#119480
@bors bors closed this as completed in 4c5e888 Aug 25, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Aug 25, 2024
Rollup merge of rust-lang#129430 - lolbinarycat:rustdoc-search-exact-case, r=notriddle

rustdoc: show exact case-sensitive matches first

fixes rust-lang#119480
@lolbinarycat
Copy link
Contributor

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

@lolbinarycat lolbinarycat reopened this Sep 3, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-rustdoc-search Area: Rustdoc's search feature C-enhancement Category: An issue proposing an enhancement or a PR with one. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants