fix(synctex): gate sync buttons to LaTeX-only projects
Build and Deploy Verso / deploy (push) Successful in 11m0s
Build and Deploy Verso / deploy (push) Successful in 11m0s
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user