 
     update_preview: (cb, force=false) =>
         if not @_render_preview
+            cb?()
+            return
+
+        # no content available, hence nothing to preview
+        if not @latex_editor.syncdoc._fully_loaded
             cb?()
             return
 

{project_tasks} = require('./project_tasks')
{salvus_client} = require('./salvus_client')

templates = $("#salvus-editor-templates")

# this regex matches the `@_get()` content iff it is a compileable latex document
RE_FULL_LATEX_CODE = new RegExp('\\\\documentclass{[^}]*}[^]*?\\\\begin{document}[^]*?\\\\end{document}', 'g')

            trash_aux_button.icon_spin(true, disable=true)
            log_output = @log.find("textarea")
            log_output.text('')
            # now we actually delete the files and report any errors in the log
            @preview.pdflatex.trash_aux_files (err, log) =>
                if err
                    log_output.text(err)
                else
                    log_output.text(log)
                # after deleting the log also clear all issues!
                @preview.pdflatex.last_latex_log = ''
                @render_error_page()
                trash_aux_button.icon_spin(false, disable=true)
            return false

        run_sage = @element.find('a[href="#latex-sage"]')
