From 170818e6fc339f1ff3fd61254011cc5d4db76a50 Mon Sep 17 00:00:00 2001 From: claude Date: Sat, 6 Jun 2026 14:50:02 +0000 Subject: [PATCH] fix(synctex): gate sync buttons to LaTeX-only projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Verso added 'qmd' and 'typ' to validRootDocExtensions, which caused isValidTeXFile() to return true for Typst/Quarto files — enabling SyncTeX UI controls for projects that never produce output.synctex.gz. Replace the open-doc extension check in canSyncToPdf with a LaTeX-only regex on the project root document path (tex|ltx|Rtex|Rnw), and add the same guard in _syncToCode so PDF-click sync never fires an API request for non-LaTeX projects. Co-Authored-By: Claude Sonnet 4.6 --- .../js/features/pdf-preview/hooks/use-synctex.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/services/web/frontend/js/features/pdf-preview/hooks/use-synctex.ts b/services/web/frontend/js/features/pdf-preview/hooks/use-synctex.ts index 1d71a50cb2..06ef1226fd 100644 --- a/services/web/frontend/js/features/pdf-preview/hooks/use-synctex.ts +++ b/services/web/frontend/js/features/pdf-preview/hooks/use-synctex.ts @@ -15,7 +15,6 @@ import { useEditorManagerContext } from '@/features/ide-react/context/editor-man import { useEditorOpenDocContext } from '@/features/ide-react/context/editor-open-doc-context' 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, @@ -177,6 +176,12 @@ export default function useSynctex(): { positionRef.current = position }, [position]) + // SyncTeX only works for LaTeX projects (requires output.synctex.gz). + // Typst and Quarto do not produce this file. + const LATEX_EXTENSIONS_RE = /\.(tex|ltx|Rtex|Rnw)$/i + const rootDocPath = rootDocId ? pathInFolder(rootDocId) : null + const isLatexRootDoc = rootDocPath ? LATEX_EXTENSIONS_RE.test(rootDocPath) : false + const _syncToCode = useCallback( ({ position = positionRef.current, @@ -187,7 +192,7 @@ export default function useSynctex(): { selectText?: string visualOffset?: number }) => { - if (!position) { + if (!isLatexRootDoc || !position) { return } @@ -240,6 +245,7 @@ export default function useSynctex(): { }) }, [ + isLatexRootDoc, pdfFile, clsiServerId, projectId, @@ -284,10 +290,10 @@ export default function useSynctex(): { }, [selectedEntities, setHasSingleSelectedDoc]) const canSyncToPdf: boolean = + isLatexRootDoc && hasSingleSelectedDoc && - cursorPosition && - openDocName && - isValidTeXFile(openDocName) + !!cursorPosition && + !!openDocName return { syncToCode,