Skip to content

Commit 0c10eb0

Browse files
Fix display of long items in search results
1 parent 95978b3 commit 0c10eb0

File tree

2 files changed

+29
-9
lines changed

2 files changed

+29
-9
lines changed

src/librustdoc/html/static/css/rustdoc.css

+24-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
:root {
1010
--nav-sub-mobile-padding: 8px;
11+
--search-typename-width: 6.75rem;
1112
}
1213

1314
/* See FiraSans-LICENSE.txt for the Fira Sans license. */
@@ -869,32 +870,39 @@ so that we can apply CSS-filters to change the arrow color in themes */
869870
gap: 1em;
870871
}
871872

872-
.search-results > a > div {
873-
flex: 1;
874-
}
875-
876873
.search-results > a > div.desc {
877874
white-space: nowrap;
878875
text-overflow: ellipsis;
879876
overflow: hidden;
877+
flex: 2;
880878
}
881879

882880
.search-results a:hover,
883881
.search-results a:focus {
884882
background-color: var(--search-result-link-focus-background-color);
885883
}
886884

885+
.search-results .result-name {
886+
display: flex;
887+
align-items: center;
888+
justify-content: start;
889+
flex: 3;
890+
}
887891
.search-results .result-name span.alias {
888892
color: var(--search-results-alias-color);
889893
}
890894
.search-results .result-name .grey {
891895
color: var(--search-results-grey-color);
892896
}
893897
.search-results .result-name .typename {
894-
display: inline-block;
895898
color: var(--search-results-grey-color);
896899
font-size: 0.875rem;
897-
width: 6.25rem;
900+
width: var(--search-typename-width);
901+
}
902+
.search-results .result-name .path {
903+
word-break: break-all;
904+
max-width: calc(100% - var(--search-typename-width));
905+
display: inline-block;
898906
}
899907

900908
.popover {
@@ -1730,6 +1738,16 @@ in source-script.js
17301738
.search-results > a > div.desc, .item-table > li > div.desc {
17311739
padding-left: 2em;
17321740
}
1741+
.search-results .result-name {
1742+
display: block;
1743+
}
1744+
.search-results .result-name .typename {
1745+
width: initial;
1746+
margin-right: 0;
1747+
}
1748+
.search-results .result-name .typename, .search-results .result-name .path {
1749+
display: inline;
1750+
}
17331751

17341752
.source-sidebar-expanded .source .sidebar {
17351753
max-width: 100vw;

src/librustdoc/html/static/js/search.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -2024,9 +2024,11 @@ function initSearch(rawSearchIndex) {
20242024

20252025
resultName.insertAdjacentHTML(
20262026
"beforeend",
2027-
`<span class="typename">${typeName}</span>`
2028-
+ ` ${item.displayPath}<span class="${type}">${name}</span>`
2029-
);
2027+
`\
2028+
<span class="typename">${typeName}</span>\
2029+
<div class="path">\
2030+
${item.displayPath}<span class="${type}">${name}</span>\
2031+
</div>`);
20302032
link.appendChild(resultName);
20312033

20322034
const description = document.createElement("div");

0 commit comments

Comments
 (0)