From 0d707ea50e005ce2ffe66bea61c613cab587f8b0 Mon Sep 17 00:00:00 2001 From: Steffen Deusch Date: Thu, 31 Oct 2024 18:41:32 +0100 Subject: [PATCH 1/3] allow searching for atoms inside backticks 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. --- assets/js/search-page.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/assets/js/search-page.js b/assets/js/search-page.js index 35768ace7..1159f5c4a 100644 --- a/assets/js/search-page.js +++ b/assets/js/search-page.js @@ -161,6 +161,18 @@ function docTokenFunction (token) { const namespaceRegex = /\:|\./ let toSplitWords = token.toString() + // clean up leading and trailing backticks + if (toSplitWords.startsWith('`') && toSplitWords.endsWith('`')) { + toSplitWords = toSplitWords.slice(1, -1) + tokens.push(token.clone().update(() => toSplitWords)) + } + + // allow searching for atoms without `:` + if (toSplitWords.startsWith(':')) { + toSplitWords = toSplitWords.slice(1) + tokens.push(token.clone().update(() => toSplitWords)) + } + if (arityRegex.test(toSplitWords)) { const withoutArity = token .toString() From ffd4276fb0ce34a56d4a69e78a7b97a93cfaac95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 31 Oct 2024 19:04:23 +0100 Subject: [PATCH 2/3] Update search-page.js --- assets/js/search-page.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/assets/js/search-page.js b/assets/js/search-page.js index 1159f5c4a..4d660f743 100644 --- a/assets/js/search-page.js +++ b/assets/js/search-page.js @@ -167,12 +167,6 @@ function docTokenFunction (token) { tokens.push(token.clone().update(() => toSplitWords)) } - // allow searching for atoms without `:` - if (toSplitWords.startsWith(':')) { - toSplitWords = toSplitWords.slice(1) - tokens.push(token.clone().update(() => toSplitWords)) - } - if (arityRegex.test(toSplitWords)) { const withoutArity = token .toString() @@ -200,6 +194,10 @@ function docTokenFunction (token) { // also make it searchable as foo_bar toSplitWords = toSplitWords.substring(1) tokens.push(token.clone().update(() => toSplitWords)) + } else if (toSplitWords.startsWith(':')) { + // allow searching for atoms without `:` + toSplitWords = toSplitWords.slice(1) + tokens.push(token.clone().update(() => toSplitWords)) } // Now split the function name (or the token, if that's all we had), From 4f816b7bbf83adeb22817f8c6c1a674697764c50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 31 Oct 2024 19:05:47 +0100 Subject: [PATCH 3/3] Update assets/js/search-page.js --- assets/js/search-page.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/js/search-page.js b/assets/js/search-page.js index 4d660f743..46e134a3a 100644 --- a/assets/js/search-page.js +++ b/assets/js/search-page.js @@ -196,7 +196,7 @@ function docTokenFunction (token) { tokens.push(token.clone().update(() => toSplitWords)) } else if (toSplitWords.startsWith(':')) { // allow searching for atoms without `:` - toSplitWords = toSplitWords.slice(1) + toSplitWords = toSplitWords.substring(1) tokens.push(token.clone().update(() => toSplitWords)) }