Display an error message when the synctex request fails (#27523)

GitOrigin-RevId: 4a57058386ba8b11dee90ef13e374411db54e2cc
This commit is contained in:
Alf Eaton
2025-07-31 14:04:36 +01:00
committed by Copybot
parent 386897266d
commit 94c8fe5b93
4 changed files with 40 additions and 3 deletions

View File

@@ -1747,6 +1747,7 @@
"sync_project_to_github_explanation": "",
"sync_to_dropbox": "",
"sync_to_github": "",
"synctex_error_recompile_and_try_again": "",
"synctex_failed": "",
"syntax_validation": "",
"tab_connecting": "",

View File

@@ -21,6 +21,12 @@ export const SynctexFileErrorToast = () => {
)
}
export const SynctexRequestErrorToast = () => {
const { t } = useTranslation()
return <span>{t('synctex_error_recompile_and_try_again')}</span>
}
const generators: GlobalToastGeneratorEntry[] = [
{
key: 'synctex:file-error',
@@ -32,6 +38,16 @@ const generators: GlobalToastGeneratorEntry[] = [
isDismissible: true,
}),
},
{
key: 'synctex:request-error',
generator: () => ({
content: <SynctexRequestErrorToast />,
type: 'warning',
autoHide: true,
delay: 4000,
isDismissible: true,
}),
},
]
export default generators
@@ -45,3 +61,13 @@ export const showFileErrorToast = () => {
})
)
}
export const showSynctexRequestErrorToast = () => {
window.dispatchEvent(
new CustomEvent('ide:show-toast', {
detail: {
key: 'synctex:request-error',
},
})
)
}

View File

@@ -17,7 +17,10 @@ import useEventListener from '@/shared/hooks/use-event-listener'
import { CursorPosition } from '@/features/ide-react/types/cursor-position'
import { isValidTeXFile } from '@/main/is-valid-tex-file'
import { PdfScrollPosition } from '@/shared/hooks/use-pdf-scroll-position'
import { showFileErrorToast } from '@/features/pdf-preview/components/synctex-toasts'
import {
showFileErrorToast,
showSynctexRequestErrorToast,
} from '@/features/pdf-preview/components/synctex-toasts'
import { sendMB } from '@/infrastructure/event-tracking'
export default function useSynctex(): {
@@ -125,7 +128,10 @@ export default function useSynctex(): {
})
}
})
.catch(debugConsole.error)
.catch(error => {
showSynctexRequestErrorToast()
debugConsole.error(error)
})
.finally(() => {
if (isMounted.current) {
setSyncToPdfInFlight(false)
@@ -236,7 +242,10 @@ export default function useSynctex(): {
})
}
})
.catch(debugConsole.error)
.catch(error => {
debugConsole.error(error)
showSynctexRequestErrorToast()
})
.finally(() => {
if (isMounted.current) {
setSyncToCodeInFlight(false)

View File

@@ -2246,6 +2246,7 @@
"sync_project_to_github_explanation": "Any changes you have made in __appName__ will be committed and merged with any updates in GitHub.",
"sync_to_dropbox": "Sync to Dropbox",
"sync_to_github": "Sync to GitHub",
"synctex_error_recompile_and_try_again": "That didnt work. Recompile and try again.",
"synctex_failed": "Couldnt find the corresponding source file",
"syntax_validation": "Code check",
"tab_connecting": "Connecting with the editor",