Skip to content

Commit f565151

Browse files
Improve loading states + hack fix seemingly spurious issue with code mirror ranges
1 parent fa8ff80 commit f565151

3 files changed

Lines changed: 36 additions & 15 deletions

File tree

src/app/search/page.tsx

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,6 @@ export default function SearchPage() {
123123
size="sm"
124124
defaultQuery={searchQuery}
125125
/>
126-
{isLoading && (
127-
<SymbolIcon className="h-4 w-4 animate-spin" />
128-
)}
129126
</div>
130127
<SettingsDropdown
131128
menuButtonClassName="w-8 h-8"
@@ -155,15 +152,22 @@ export default function SearchPage() {
155152
{/* Search Results & Code Preview */}
156153
<ResizablePanelGroup direction="horizontal">
157154
<ResizablePanel minSize={20}>
158-
<SearchResultsPanel
159-
fileMatches={fileMatches}
160-
onOpenFileMatch={(fileMatch) => {
161-
setSelectedFile(fileMatch);
162-
}}
163-
onMatchIndexChanged={(matchIndex) => {
164-
setSelectedMatchIndex(matchIndex);
165-
}}
166-
/>
155+
{isLoading ? (
156+
<div className="flex flex-col items-center justify-center h-full gap-2">
157+
<SymbolIcon className="h-6 w-6 animate-spin" />
158+
<p className="font-semibold text-center">Searching...</p>
159+
</div>
160+
) : (
161+
<SearchResultsPanel
162+
fileMatches={fileMatches}
163+
onOpenFileMatch={(fileMatch) => {
164+
setSelectedFile(fileMatch);
165+
}}
166+
onMatchIndexChanged={(matchIndex) => {
167+
setSelectedMatchIndex(matchIndex);
168+
}}
169+
/>
170+
)}
167171
</ResizablePanel>
168172
<ResizableHandle withHandle={selectedFile !== undefined} />
169173
<ResizablePanel

src/app/search/searchResultsPanel.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ export const SearchResultsPanel = ({
2828
onOpenFileMatch,
2929
onMatchIndexChanged,
3030
}: SearchResultsPanelProps) => {
31+
32+
if (fileMatches.length === 0) {
33+
return (
34+
<div className="flex flex-col items-center justify-center h-full">
35+
<p className="text-sm text-muted-foreground">No results found</p>
36+
</div>
37+
);
38+
}
39+
3140
return (
3241
<ScrollArea className="h-full">
3342
{fileMatches.map((fileMatch, index) => (

src/hooks/useExtensionWithDependency.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,17 @@ export function useExtensionWithDependency(
1717

1818
useEffect(() => {
1919
if (view) {
20-
view.dispatch({
21-
effects: compartment.reconfigure(extensionFactory()),
22-
});
20+
try {
21+
view.dispatch({
22+
effects: compartment.reconfigure(extensionFactory()),
23+
});
24+
25+
// @note: we were getting "RangeError: Position X is out of range for changeset of length Y" errors
26+
// spuriously for some reason. This is a dirty hack to prevent codemirror from crashing the app
27+
// in those cases.
28+
} catch (error) {
29+
console.error(error);
30+
}
2331
}
2432
// eslint-disable-next-line react-hooks/exhaustive-deps
2533
}, deps);

0 commit comments

Comments
 (0)