Skip to content

Commit 1b07da1

Browse files
authored
Rollup merge of #113823 - GuillaumeGomez:fix-results-search-alias-display, r=notriddle
Fix results search alias display Currently it's displayed like this: ![Screenshot from 2023-07-18 14-23-35](https://github.com/rust-lang/rust/assets/3050060/119d8f18-b298-4e6f-9571-9f678fc19126) With this fix: ![Screenshot from 2023-07-18 14-23-29](https://github.com/rust-lang/rust/assets/3050060/679d6241-420e-4f13-be78-dc061cbc488a) r? `@notriddle`
2 parents c88864c + 8f5787a commit 1b07da1

File tree

4 files changed

+18
-22
lines changed

4 files changed

+18
-22
lines changed

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ so that we can apply CSS-filters to change the arrow color in themes */
888888
justify-content: start;
889889
flex: 3;
890890
}
891-
.search-results .result-name span.alias {
891+
.search-results .result-name .alias {
892892
color: var(--search-results-alias-color);
893893
}
894894
.search-results .result-name .grey {
@@ -904,6 +904,9 @@ so that we can apply CSS-filters to change the arrow color in themes */
904904
max-width: calc(100% - var(--search-typename-width));
905905
display: inline-block;
906906
}
907+
.search-results .result-name .path > * {
908+
display: inline;
909+
}
907910

908911
.popover {
909912
position: absolute;

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

+11-18
Original file line numberDiff line numberDiff line change
@@ -2108,29 +2108,22 @@ function initSearch(rawSearchIndex) {
21082108
const resultName = document.createElement("div");
21092109
resultName.className = "result-name";
21102110

2111-
if (item.is_alias) {
2112-
const alias = document.createElement("span");
2113-
alias.className = "alias";
2114-
2115-
const bold = document.createElement("b");
2116-
bold.innerText = item.alias;
2117-
alias.appendChild(bold);
2118-
2119-
alias.insertAdjacentHTML(
2120-
"beforeend",
2121-
"<i class=\"grey\">&nbsp;- see&nbsp;</i>");
2111+
resultName.insertAdjacentHTML(
2112+
"beforeend",
2113+
`<span class="typename">${typeName}</span>`);
2114+
link.appendChild(resultName);
21222115

2123-
resultName.appendChild(alias);
2116+
let alias = " ";
2117+
if (item.is_alias) {
2118+
alias = ` <div class="alias">\
2119+
<b>${item.alias}</b><i class="grey">&nbsp;- see&nbsp;</i>\
2120+
</div>`;
21242121
}
2125-
21262122
resultName.insertAdjacentHTML(
21272123
"beforeend",
2128-
`\
2129-
<span class="typename">${typeName}</span>\
2130-
<div class="path">\
2131-
${item.displayPath}<span class="${type}">${name}</span>\
2124+
`<div class="path">${alias}\
2125+
${item.displayPath}<span class="${type}">${name}</span>\
21322126
</div>`);
2133-
link.appendChild(resultName);
21342127

21352128
const description = document.createElement("div");
21362129
description.className = "desc";

tests/rustdoc-gui/search-reexport.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ write: (".search-input", "AliasForTheStdReexport")
2626
wait-for: "//a[@class='result-import']"
2727
assert-text: (
2828
"a.result-import .result-name",
29-
"AliasForTheStdReexport - see re-export test_docs::TheStdReexport",
29+
"re-export AliasForTheStdReexport - see test_docs::TheStdReexport",
3030
)
3131
// Same thing again, we click on it to ensure the background is once again set as expected.
3232
click: "//a[@class='result-import']"

tests/rustdoc-gui/search-result-color.goml

+2-2
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,8 @@ define-function: (
368368
// Waiting for the search results to appear...
369369
wait-for: "#search-tabs"
370370
// Checking that the colors for the alias element are the ones expected.
371-
assert-css: (".result-name > .alias", {"color": |alias|})
372-
assert-css: (".result-name > .alias > .grey", {"color": |grey|})
371+
assert-css: (".result-name .path .alias", {"color": |alias|})
372+
assert-css: (".result-name .path .alias > .grey", {"color": |grey|})
373373
// Leave the search results to prevent reloading with an already filled search input.
374374
press-key: "Escape"
375375
},

0 commit comments

Comments
 (0)