Bug: TOC slow to open on large file

Paul Solt's Avatar

Paul Solt

Sep 01, 2020 @ 02:26 PM

Toggling my sidebar TOC (Command + Shift + T) is slow with a 65,000 word file. It takes 2-3 seconds, see my video below to both show/hide the TOC.

TOC should be "cached" so it's a fast lookup, or you need to work backwards/forwards from my current scroll position and only display the last 20 elements, calculate the rest in a background thread and then update the UI with the full list.

Once it's cached, I don't see why it needs to be recalculated if I'm just hiding/showing the TOC.

From a "view" standpoint, it shouldn't be recalculating my scroll position, instead just show the content where I currently am. You shouldn't need to relayout everything if I'm at a specific scroll position, just work back or forwards relative my scroll position.

https://www.loom.com/share/6142127614c94db88d20bc601781e7e5

  1. Support Staff 1 Posted by Fletcher on Mar 04, 2022 @ 05:29 PM

    Fletcher's Avatar

    Going back through open issues that didn't have a solution or was still
    working on.

    The delay when toggling the TOC is related to adjusting the text editor
    view, not loading the TOC data. If you put the insertion point at the
    top of the document and toggle, it's fast. If you are at the bottom,
    it's slow. This is part of macOS, and to my knowledge there is not much
    I can do about it.

    The TOC data is cached, but when the TOC is hidden there is no reason to
    update the data (e.g if someone never uses the TOC, they shouldn't take
    the performance hit of updating it with every keystroke.) So when you
    toggle the TOC on, it needs to be updated. But this delay comes after
    the TOC appears (if your insertion point is at the top).

    You can demonstrate this by cutting all text, then collapsing the TOC.
    Paste the text back in, move insertion to top, and then expand TOC.
    You'll see a slight delay before the TOC contents are loaded, but the
    panel expands quickly.

    Replacing the data in MMDC v4 is a bit slow, but again not the primary
    issue here. Regardless, MMDC v5 uses a different approach that is much
    faster overall, but it doesn't change the text layout issue that is the
    primary problem.

    If you're interested in the "almost-beta" of v5, you can download here:

    https://s3.amazonaws.com/files.multimarkdown.com/composer5/MMDComposer5-2022-03-02.zip

    Fletcher

Reply to this discussion

Internal reply

        No formatting (switch to Markdown)

        Already uploaded files

        • Slow_TOC_open_on_large_60000_word_file.png 367 KB

          You can attach files up to 10MB

            If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

              Keyboard shortcuts

              Generic

              ? Show this help
              ESC Blurs the current field

              Comment Form

              r Focus the comment reply box
              ^ + ↩ Submit the comment

              You can use Command ⌘ instead of Control ^ on Mac