Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions components/file-diff-viewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,9 @@ export function FileDiffViewer({
return null
}

file.initTheme(mounted ? theme : 'light')
// Initialize with the current theme
const currentTheme = mounted ? theme : 'light'
file.initTheme(currentTheme)

// Wrap file.init() in try-catch to handle diff parsing errors
try {
Expand All @@ -219,6 +221,13 @@ export function FileDiffViewer({
}
}, [diffData, mounted, theme, viewMode])

// Re-initialize theme when it changes
useEffect(() => {
if (diffFile && mounted) {
diffFile.initTheme(theme)
}
}, [diffFile, theme, mounted])

if (!selectedFile) {
// Don't show "No file selected" during initial loading
if (isInitialLoading) {
Expand Down Expand Up @@ -271,7 +280,7 @@ export function FileDiffViewer({
return (
<div className="flex items-center justify-center h-full p-4">
<div className="text-center">
<div className="mb-4 text-4xl">📦</div>
<div className="mb-4 text-4xl">??</div>
<p className="text-muted-foreground mb-2 text-sm md:text-base font-medium">Binary File</p>
<p className="text-xs md:text-sm text-muted-foreground">This is binary content and cannot be displayed</p>
</div>
Expand Down Expand Up @@ -369,9 +378,9 @@ export function FileDiffViewer({

try {
return (
<div className="git-diff-view-container w-full">
<div className="git-diff-view-container w-full" data-theme={mounted ? theme : 'light'}>
<DiffView
key={`${selectedFile}-${diffData?.filename}`}
key={`${selectedFile}-${diffData?.filename}-${theme}`}
diffFile={diffFile}
diffViewMode={diffViewMode}
diffViewTheme={mounted ? theme : 'light'}
Expand Down
Loading