Skip to content

Commit c9a7131

Browse files
fix(web): Repo name whitespace bug (#705)
* Fix: Wrap regex-escaped suggestions with spaces in quotes Co-authored-by: brendan <brendan@sourcebot.dev> * Fix: Wrap repository names with spaces in quotes for auto-suggestions Co-authored-by: brendan <brendan@sourcebot.dev> * Fix: Wrap repo names with spaces in quotes for auto-suggestions Co-authored-by: brendan <brendan@sourcebot.dev> --------- Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent f6971d5 commit c9a7131

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Fixed
11+
- Fixed auto-suggestion dropdown breaking queries with whitespace in repository names. Repository names containing spaces are now properly wrapped in quotes. [#705](https://github.com/sourcebot-dev/sourcebot/pull/705)
12+
1013
## [4.10.6] - 2025-12-28
1114

1215
### Fixed

packages/web/src/app/[domain]/components/searchBar/searchSuggestionsBox.test.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,19 @@ test('completeSuggestions regex escapes suggestions when regexEscaped is true',
219219
expect(newQuery).toEqual(expectedNewQuery);
220220
expect(newCursorPosition).toBe(newQuery.length);
221221
});
222+
223+
test('completeSuggestions wraps regex-escaped suggestions in quotes when they contain spaces', () => {
224+
const query = "repo:My";
225+
const { newQuery, newCursorPosition } = completeSuggestion({
226+
query,
227+
suggestionQuery: "My",
228+
suggestion: "My Project",
229+
trailingSpace: true,
230+
regexEscaped: true,
231+
cursorPosition: query.length,
232+
});
233+
234+
const expectedNewQuery = String.raw`repo:"^My Project$" `;
235+
expect(newQuery).toEqual(expectedNewQuery);
236+
expect(newCursorPosition).toBe(newQuery.length);
237+
});

packages/web/src/app/[domain]/components/searchBar/searchSuggestionsBox.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,13 @@ export const completeSuggestion = (params: {
504504
}
505505

506506
if (regexEscaped) {
507-
part = part + `^${escapeStringRegexp(suggestion)}$`;
507+
const escapedSuggestion = `^${escapeStringRegexp(suggestion)}$`;
508+
// Wrap in quotes if the original suggestion contains spaces
509+
if (suggestion.includes(" ")) {
510+
part = part + `"${escapedSuggestion}"`;
511+
} else {
512+
part = part + escapedSuggestion;
513+
}
508514
} else if (suggestion.includes(" ")) {
509515
part = part + `"${suggestion}"`;
510516
} else {

0 commit comments

Comments
 (0)