diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6db92ae..810f721 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# Changelog
+## Unreleased
+
+- **search**: Opening a query in browser now correctly preserves the selected pattern type from the pattern type selector.
+
## [Search improvements, pattern selector, and proxy support](https://github.com/raycast/extensions/pull/15625) - 2024-11-30
- **search**: The search pattern selector is now enabled by default, allowing you to easily toggle between standard, literal, regexp, and other search patterns. This can be disabled in the extension preferences if you find the dropdown takes up too much space in the search bar.
diff --git a/src/components/SearchCommand.tsx b/src/components/SearchCommand.tsx
index 2e913dd..5d14596 100644
--- a/src/components/SearchCommand.tsx
+++ b/src/components/SearchCommand.tsx
@@ -115,7 +115,7 @@ export default function SearchCommand({ src, props }: { src: Sourcegraph; props?
icon={{ source: Icon.Window }}
actions={
-
+
}
/>
@@ -144,6 +144,7 @@ export default function SearchCommand({ src, props }: { src: Sourcegraph; props?
key={`result-item-${i}`}
searchResult={searchResult}
searchText={searchText}
+ patternType={patternType}
src={src}
setSearchText={setSearchText}
/>
@@ -226,8 +227,12 @@ function resultActions(url: string, customActions?: CustomResultActions) {
);
}
-function getQueryURL(src: Sourcegraph, query: string) {
- return link.new(src, "/search", new URLSearchParams({ q: query }));
+function getQueryURL(src: Sourcegraph, query: string, pattern: PatternType | undefined) {
+ const params: Record = { q: query };
+ if (pattern) {
+ params.patternType = pattern;
+ }
+ return link.new(src, "/search", new URLSearchParams(params));
}
// https://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
@@ -297,15 +302,17 @@ function makeFileActions(src: Sourcegraph, opts: { path: string; repository: str
function SearchResultItem({
searchResult,
searchText,
+ patternType,
src,
setSearchText,
}: {
searchResult: SearchResult;
searchText: string;
+ patternType: PatternType | undefined;
src: Sourcegraph;
setSearchText: (text: string) => void;
}) {
- const queryURL = getQueryURL(src, searchText);
+ const queryURL = getQueryURL(src, searchText, patternType);
const { match } = searchResult;
// Branches is a common property for setting a revision