Skip to content

Commit 6197d18

Browse files
authored
allow searching for atoms inside backticks (#1960)
In the LV repo you were not able to search for atoms inside backticks, for example when searching for "validate_attrs" the corresponding option of the `Phoenix.Component.slot/3` macro could not be found. This commit fixes this by stripping the backticks from tokens and also removing trailing colons.
1 parent a4cb212 commit 6197d18

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

assets/js/search-page.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ function docTokenFunction (token) {
161161
const namespaceRegex = /\:|\./
162162
let toSplitWords = token.toString()
163163

164+
// clean up leading and trailing backticks
165+
if (toSplitWords.startsWith('`') && toSplitWords.endsWith('`')) {
166+
toSplitWords = toSplitWords.slice(1, -1)
167+
tokens.push(token.clone().update(() => toSplitWords))
168+
}
169+
164170
if (arityRegex.test(toSplitWords)) {
165171
const withoutArity = token
166172
.toString()
@@ -188,6 +194,10 @@ function docTokenFunction (token) {
188194
// also make it searchable as foo_bar
189195
toSplitWords = toSplitWords.substring(1)
190196
tokens.push(token.clone().update(() => toSplitWords))
197+
} else if (toSplitWords.startsWith(':')) {
198+
// allow searching for atoms without `:`
199+
toSplitWords = toSplitWords.substring(1)
200+
tokens.push(token.clone().update(() => toSplitWords))
191201
}
192202

193203
// Now split the function name (or the token, if that's all we had),

0 commit comments

Comments
 (0)