Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markdown highlighting is kinda slow #104

Closed
suhr opened this issue Mar 2, 2016 · 13 comments
Closed

Markdown highlighting is kinda slow #104

suhr opened this issue Mar 2, 2016 · 13 comments
Labels
Milestone

Comments

@suhr
Copy link
Contributor

suhr commented Mar 2, 2016

It should react instantly, but instead it takes about about 1-1.5 seconds to highlight something like *test*.

@pbek
Copy link
Owner

pbek commented Mar 2, 2016

Thank you for the report, @suhr. The highlighting is done every second by a customized version of PEG Markdown Highlight. Do you think that is a problem?
I didn't want to highlight more than once a second because the possible load for huge files...

@suhr
Copy link
Contributor Author

suhr commented Mar 2, 2016

Do you think that is a problem?

Yes, editing doesn't feel smooth.

I didn't want to highlight more than once a second because the possible load for huge files...

You can parse markdown in a small window before parsing the whole file, for example.

@pbek
Copy link
Owner

pbek commented Mar 2, 2016

You can parse markdown in a small window before parsing the whole file, for example.

Can you please explain in more detail what you are referring to. 😸

@suhr
Copy link
Contributor Author

suhr commented Mar 3, 2016

I'm not actually referring anything. Just a simple idea:

  • Editing usually happens in a small area (even with multiple cursors), and parts of text with markup are usually quite short.
  • Parsing small amounts of text is (or should be) quite cheap
  • So we can have a small window around the cursor (for example, ~1024 bytes or even more) and parse&highlight text in it immediately on change
  • You still have to parse the whole file, but you can do it less frequently

There're probably better ways to handle changing markdown (with something like incomplete syntax tree?), but I'm not aware of any.

@pbek
Copy link
Owner

pbek commented Mar 3, 2016

That if the whole markdown file is one big code block (like I know some people are using it)?
And so far I only was able to parse the whole QTextDocument of the QTextEdit object with the highlighter. It has to set the styles directly in the document...
Do you have any suggestions for a better markdown highlighter for Qt QTextEditor that does everything we are currently doing. I wasn't aware of any so far.

@pbek pbek added Type: Feature adds functionality Help wanted labels Mar 3, 2016
@suhr
Copy link
Contributor Author

suhr commented Mar 3, 2016

Do you have any suggestions for a better markdown highlighter for Qt QTextEditor that does everything we are currently doing.

Um... Nope. I may know a bit about parsing, but I don't know Qt.

@pbek
Copy link
Owner

pbek commented Mar 3, 2016

Currently the highlighting for the QTextEdit is done here: https://github.com/pbek/qmarkdowntextedit/blob/develop/highlighter.cpp in QMarkdownHighlighter::highlight().

@pbek
Copy link
Owner

pbek commented Mar 3, 2016

Of course we can always make a setting that allows to set the ms time interval between highlighting commands, most systems would allow smaller intervals.

@pbek
Copy link
Owner

pbek commented Jun 11, 2016

from the v16.06.3 changelog

  • you can now set the markdown highlighting interval in the interface settings
    (for Issue #104)
    • if you set it to 0 the highlighting will be disabled
      (for Issue #197)

@pbek
Copy link
Owner

pbek commented Jun 11, 2016

There now is a new release, could you please test it and report if the new features work for you?

@pbek pbek added this to the 16.06.3 milestone Jun 11, 2016
@suhr
Copy link
Contributor Author

suhr commented Jun 11, 2016

It works. With a small highlighting interval it's much nicer to use, though it is still not instant like ghostwriter.

@pbek
Copy link
Owner

pbek commented Jun 11, 2016

You are always welcome to write a faster one. 👍

@pbek pbek closed this as completed Jun 11, 2016
@pbek
Copy link
Owner

pbek commented Nov 27, 2016

@suhr @jd666

16.11.15

  • a new markdown parser and highlighter was now implemented from
    the scratch to allow a higher parsing speed and more flexibility in
    the future
    • text will now be instantly highlighted, there is no
      highlighting-interval setting any more
    • now you also can change the styling in the settings or
      enable/disable the highlighting without re-starting the application
    • please report issues with the new highlighter if you find any
  • markdown tables are now supported by the new markdown highlighter
    • the mono-space code font is used for it
    • you can change the highlighting color and other styles in the settings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants