Skip to content

Commit

Permalink
Fix a typing issue
Browse files Browse the repository at this point in the history
  • Loading branch information
James-Yu committed Apr 15, 2024
1 parent a7aa1fb commit 8abc746
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/locate/synctex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,30 +221,26 @@ function toPDF(args?: {line: number, filePath: string}, forcedViewer: 'auto' | '
logger.log('No root file found.')
return
}
if (!pdfFile) {
pdfFile = lw.file.getPdfPath(rootFile)
}
const targetPdfFile = pdfFile ?? lw.file.getPdfPath(rootFile)
if (vscode.window.activeTextEditor.document.lineCount === line &&
vscode.window.activeTextEditor.document.lineAt(line - 1).text === '') {
line -= 1
}
if (forcedViewer === 'external' || (forcedViewer === 'auto' && configuration.get('view.pdf.viewer') === 'external') ) {
syncTeXExternal(line, pdfFile, rootFile)
syncTeXExternal(line, targetPdfFile, rootFile)
return
}

callSyncTeXToPDF(line, character, filePath, pdfFile, configuration.get('synctex.indicator') as 'none' | 'circle' | 'rectangle').then((record) => {
if (pdfFile) {
void lw.viewer.locate(pdfFile, record)
}
callSyncTeXToPDF(line, character, filePath, targetPdfFile, configuration.get('synctex.indicator') as 'none' | 'circle' | 'rectangle').then((record) => {
void lw.viewer.locate(targetPdfFile, record)
}).catch(() => {
try {
logger.log(`Forward with synctex.js from ${filePath} to ${pdfFile} on line ${line}.`)
const record = syncTeXToPDF(line, filePath, pdfFile)
const record = syncTeXToPDF(line, filePath, targetPdfFile)
if (!record) {
return
}
void lw.viewer.locate(pdfFile, record)
void lw.viewer.locate(targetPdfFile, record)
} catch (e) {
logger.logError('Forward SyncTeX failed.', e)
}
Expand Down

0 comments on commit 8abc746

Please sign in to comment.