mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-12 04:15:30 +00:00
Improve loading states + hack fix seemingly spurious issue with code mirror ranges
This commit is contained in:
parent
fa8ff8088a
commit
f5651515b2
3 changed files with 36 additions and 15 deletions
|
|
@ -123,9 +123,6 @@ export default function SearchPage() {
|
||||||
size="sm"
|
size="sm"
|
||||||
defaultQuery={searchQuery}
|
defaultQuery={searchQuery}
|
||||||
/>
|
/>
|
||||||
{isLoading && (
|
|
||||||
<SymbolIcon className="h-4 w-4 animate-spin" />
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
<SettingsDropdown
|
<SettingsDropdown
|
||||||
menuButtonClassName="w-8 h-8"
|
menuButtonClassName="w-8 h-8"
|
||||||
|
|
@ -155,15 +152,22 @@ export default function SearchPage() {
|
||||||
{/* Search Results & Code Preview */}
|
{/* Search Results & Code Preview */}
|
||||||
<ResizablePanelGroup direction="horizontal">
|
<ResizablePanelGroup direction="horizontal">
|
||||||
<ResizablePanel minSize={20}>
|
<ResizablePanel minSize={20}>
|
||||||
<SearchResultsPanel
|
{isLoading ? (
|
||||||
fileMatches={fileMatches}
|
<div className="flex flex-col items-center justify-center h-full gap-2">
|
||||||
onOpenFileMatch={(fileMatch) => {
|
<SymbolIcon className="h-6 w-6 animate-spin" />
|
||||||
setSelectedFile(fileMatch);
|
<p className="font-semibold text-center">Searching...</p>
|
||||||
}}
|
</div>
|
||||||
onMatchIndexChanged={(matchIndex) => {
|
) : (
|
||||||
setSelectedMatchIndex(matchIndex);
|
<SearchResultsPanel
|
||||||
}}
|
fileMatches={fileMatches}
|
||||||
/>
|
onOpenFileMatch={(fileMatch) => {
|
||||||
|
setSelectedFile(fileMatch);
|
||||||
|
}}
|
||||||
|
onMatchIndexChanged={(matchIndex) => {
|
||||||
|
setSelectedMatchIndex(matchIndex);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</ResizablePanel>
|
</ResizablePanel>
|
||||||
<ResizableHandle withHandle={selectedFile !== undefined} />
|
<ResizableHandle withHandle={selectedFile !== undefined} />
|
||||||
<ResizablePanel
|
<ResizablePanel
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,15 @@ export const SearchResultsPanel = ({
|
||||||
onOpenFileMatch,
|
onOpenFileMatch,
|
||||||
onMatchIndexChanged,
|
onMatchIndexChanged,
|
||||||
}: SearchResultsPanelProps) => {
|
}: SearchResultsPanelProps) => {
|
||||||
|
|
||||||
|
if (fileMatches.length === 0) {
|
||||||
|
return (
|
||||||
|
<div className="flex flex-col items-center justify-center h-full">
|
||||||
|
<p className="text-sm text-muted-foreground">No results found</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollArea className="h-full">
|
<ScrollArea className="h-full">
|
||||||
{fileMatches.map((fileMatch, index) => (
|
{fileMatches.map((fileMatch, index) => (
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,17 @@ export function useExtensionWithDependency(
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (view) {
|
if (view) {
|
||||||
view.dispatch({
|
try {
|
||||||
effects: compartment.reconfigure(extensionFactory()),
|
view.dispatch({
|
||||||
});
|
effects: compartment.reconfigure(extensionFactory()),
|
||||||
|
});
|
||||||
|
|
||||||
|
// @note: we were getting "RangeError: Position X is out of range for changeset of length Y" errors
|
||||||
|
// spuriously for some reason. This is a dirty hack to prevent codemirror from crashing the app
|
||||||
|
// in those cases.
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, deps);
|
}, deps);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue