Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function addSynctexCommands(
app: JupyterFrontEnd,
editorTracker: IEditorTracker,
pdfTracker: IPDFJSTracker,
serverSettings: ServerConnection.ISettings
): DisposableSet {
const disposables = new DisposableSet();
const hasPDFWidget = () => !!pdfTracker.currentWidget;
const hasEditorWidget = () => !!editorTracker.currentWidget;
// Add the command for the PDF-to-editor mapping.
disposables.add(
app.commands.addCommand(CommandIDs.synctexEdit, {
execute: () => {
// Get the pdf widget that had its contextMenu activated.
let widget = pdfTracker.currentWidget;
if (widget) {
// Get the page number.
const pos = widget.content.position;
// Request the synctex position for the PDF
return synctexEditRequest(
.then(([settings]) => {
let disposables = new DisposableSet();
const onSettingsUpdated = (settings: ISettingRegistry.ISettings) => {
// Get the new value of the synctex setting.
const val = settings.get('synctex').composite as boolean | null;
synctex = val === true || val === false ? val : true;
// Trash any existing synctex commands
disposables.dispose();
// If SyncTeX is enabled, add the commands.
if (synctex) {
disposables = addSynctexCommands(
app,
editorTracker,
pdfTracker,
serverSettings
);
}