Skip to content

Slow syntax highlighting #64681

Open
Open

Description

@ci70
  • VSCode Version: Insider 1.30
  • OS Version: Windows 10 1607 LTSB x64

Steps to Reproduce:

  1. Load large C++ file (60k LOC)
  2. Observe the slowness. Takes like 10s to highlight the code.

Does this issue occur when all extensions are disabled?: Yes

Activity

  1. alexdima commented on Dec 11, 2018

    @alexdima
    Member

    Today, syntax highlighting is running on the main thread and is implemented by constantly yielding in order to keep the thread responsive. The speed is further influenced by the grammar. This can be improved if we move the tokenization to a separate thread.

  2. added
    feature-request
    on Dec 11, 2018
  3. ci70 commented on Dec 11, 2018

    @ci70
    Author

    Excellent. Hope to see it implemented ASAP.

  4. ci70 commented on Aug 8, 2019

    @ci70
    Author

    Has this been fixed?! It's been almost 9 freaking months!!!

  5. matter123 commented on Aug 8, 2019

    @matter123

    @optomux I co-maintain the C++ grammar if this still appears broken, could you create an issue in https://github.com/jeff-hykin/cpp-textmate-grammar with an example file that reproduces. Alternatively, if the file is confidential, I can provide steps to collect performance information without revealing the file.

  6. ci70 commented on Aug 8, 2019

    @ci70
    Author

    Open sqlite3 which is pretty large.

  7. matter123 commented on Aug 8, 2019

    @matter123

    @optomux After processing the 223k loc sqlite.c There does not seem to be much that can be done on the grammar side. While it did take 11.7 seconds to evaluate the patterns inside the grammar, no individual pattern took an unexpectedly long amount of time.

    If you are having similarly long times on significantly shorter files, there may still be an issue in the grammar, however.

  8. jasonwilliams commented on Dec 11, 2019

    @jasonwilliams
    Contributor

    Today, syntax highlighting is running on the main thread and is implemented by constantly yielding in order to keep the thread responsive. The speed is further influenced by the grammar. This can be improved if we move the tokenization to a separate thread.

    Alexandru Dima (@alexdima) are there plans to do this?

  9. 6 remaining items

  10. ebkgne commented on Jul 19, 2021

    @ebkgne

    The highlighting starts doing like in Balrrach's GIF for me when I activate CPP intelisense

  11. Balrrach commented on Jul 22, 2021

    @Balrrach

    Is there a plan to fix this problem?
    If so, how long will it take?
    Is it a hard problem to solve or a design problem?

  12. jasonwilliams commented on Jul 22, 2021

    @jasonwilliams
    Contributor

    Is there a plan to fix this problem?
    If so, how long will it take?
    Is it a hard problem to solve or a design problem?

    As I mentioned in my comment above it looks like the work to fix this was moved to this thread #77140 it might be worth asking there. It looks to have gone dark.

  13. ebkgne commented on Aug 13, 2021

    @ebkgne

    Baltasar del Sol de Haro (@Balrrach) & others with this problem

    because this latency really bothered me while coding, I prefer to use standard code colorization for the time being.

    Go to settings (ctrl + ,) look for "C_cpp: Enhanced Colorization" and set it to "Disabled" .

    I also found the extension "Syntax Highlighter" wich does a good job at better colorizing with much more managable latency.

  14. SebiTimeWaster commented on Dec 14, 2021

    @SebiTimeWaster

    a 78KB HTML file takes FIFTEEN MINUTES to color code in which VSCode is completely unresponsive and my OS wants to kill the task.

    ARE YOU FOR REAL.

  15. shubhamvermaa commented on Jul 1, 2023

    @shubhamvermaa

    If I'm not mistaken VS Code extended syntax coloring behaviour by including the extension "Better C++ Syntax" to the base program. Well, I have observed that this problem only occurs with tokens that are not colorised with the standard VS Code syntax highlighting. In the next gif one can observed how the Strings in the cout get quickly green color when the line gets commented but, on the other hand, the rest of the tokens in the line take much longer.

    syntax-highlighting syntax-highlighting

    Thus, I think this issue is strongly related to the way "Better C++ Syntax" extension works internally so the fix goes by adding the behaviour the extension provides to the base program in the way it is done with the base syntax highlighting.

    Is there a solution yet? i really like my custom theme.

  16. bpGusar commented on Dec 6, 2023

    @bpGusar

    Has anyone managed to fix this?

  17. jasonwilliams commented on Dec 6, 2023

    @jasonwilliams
    Contributor

    Since this thread was created tokenization has been made asynchronous, this may help somewhat, I haven't tried the sqlite.c example above so I don't know how different performance is today compared to then.

    Secondly, TreeSitter should help with tokenization and syntax highlighting but faces some challenges, you can follow the thread here: #50140

  18. RabiulAwalOvi commented on Dec 30, 2023

    @RabiulAwalOvi

    Has anyone managed to fix this?

    2 (somewhat works) approach

    1. as roch (@ebkgne) mentioned: turning off the enhanced color ( form setting Ctrl +, ) And search for enhanced colorization. disable that.
    2. If enhanced colorization is so damn necessary consider increasing the IntelliSense speed . in setting search for Intelli Sense Update Delay and make it 500 (minimum possible)
  19. d-strygwyr commented on Mar 28, 2024

    @d-strygwyr

    how to fix this issue 😭, happened to me too

    2024-03-28.19-07-44.mp4

    need to scroll first then the color changes to gray (comment color)

  20. shubhamvermaa commented on Mar 28, 2024

    @shubhamvermaa
  21. d-strygwyr commented on Mar 28, 2024

    @d-strygwyr

    Turn off enhanced colonization.
    Screenshot 2024-03-28 195604

    where ? i can't found it 😭

  22. d-strygwyr commented on Mar 28, 2024

    @d-strygwyr

    i'm work with javascript btw

  23. shubhamvermaa commented on Mar 28, 2024

    @shubhamvermaa
  24. shubhamvermaa commented on Mar 28, 2024

    @shubhamvermaa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requesttokenization

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions