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

Slow syntax highlighting #64681

Open
ci70 opened this issue Dec 9, 2018 · 29 comments
Open

Slow syntax highlighting #64681

ci70 opened this issue Dec 9, 2018 · 29 comments
Labels
feature-request Request for new features or functionality tokenization Text tokenization
Milestone

Comments

@ci70
Copy link

ci70 commented Dec 9, 2018

  • 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

@alexdima
Copy link
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.

@alexdima alexdima added the feature-request Request for new features or functionality label Dec 11, 2018
@ci70
Copy link
Author

ci70 commented Dec 11, 2018

Excellent. Hope to see it implemented ASAP.

@ci70
Copy link
Author

ci70 commented Dec 12, 2018

@vscodebot vscodebot bot removed the insiders label Dec 13, 2018
@alexdima alexdima added the tokenization Text tokenization label Dec 19, 2018
@alexdima alexdima removed their assignment Dec 19, 2018
@alexdima alexdima added this to the Backlog milestone Dec 19, 2018
@ci70
Copy link
Author

ci70 commented Aug 8, 2019

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

@matter123
Copy link

@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.

@ci70
Copy link
Author

ci70 commented Aug 8, 2019

Open sqlite3 which is pretty large.

@matter123
Copy link

@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.

@jasonwilliams
Copy link
Contributor

jasonwilliams commented Dec 11, 2019

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.

@alexdima are there plans to do this?

@nxrighthere
Copy link

It would be great to improve this with multi-threading, quite annoying to wait for syntax update in large amalgamated source code after every tiny change by an external application.

@nhuhoang0701
Copy link

I have the same issue after updating the C++ extension to version 0.28.*. I reinstall it back to version 0.27.1 and it fixes the issue partly. The color isn't still rendered too fast but at least version 0.27 is much better.

@jasonwilliams
Copy link
Contributor

It looks like the work in #77140 may help solve this but I’m not 100% sure

@ebkgne
Copy link

ebkgne commented Jul 10, 2021

for me still not working here ...

@Balrrach
Copy link

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

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.

@marktimarev
Copy link

I just installed VS Code to try it.
When I typing code . in the directory of a project (of a really small size, about 10 000 lines in JS) I first wait about 3 seconds to see the text and then 2 seconds more to get the text from plain white to highlighted.
So, 2021 and the issue is still not solved at all. Giving the pace of solving so basic problems, I do not know what to think about this editor tbh...

@ebkgne
Copy link

ebkgne commented Jul 19, 2021

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

@Balrrach
Copy link

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?

@jasonwilliams
Copy link
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.

@ebkgne
Copy link

ebkgne commented Aug 13, 2021

@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.

@SebiTimeWaster
Copy link

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.

@shubhamvermaa
Copy link

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.

@bpGusar
Copy link

bpGusar commented Dec 6, 2023

Has anyone managed to fix this?

@jasonwilliams
Copy link
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

@RabiulAwalOvi
Copy link

Has anyone managed to fix this?

2 (somewhat works) approach

  1. as @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)

@d-strygwyr
Copy link

d-strygwyr commented Mar 28, 2024

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)

@shubhamvermaa
Copy link

shubhamvermaa commented Mar 28, 2024 via email

@d-strygwyr
Copy link

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

where ? i can't found it 😭

@d-strygwyr
Copy link

i'm work with javascript btw

@shubhamvermaa
Copy link

shubhamvermaa commented Mar 28, 2024 via email

@shubhamvermaa
Copy link

shubhamvermaa commented Mar 28, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality tokenization Text tokenization
Projects
None yet
Development

No branches or pull requests