microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
160.57k stars 28.13k forks source link

Slow syntax highlighting #64681

Open ci70 opened 5 years ago

ci70 commented 5 years ago

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 commented 5 years ago

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.

ci70 commented 5 years ago

Excellent. Hope to see it implemented ASAP.

ci70 commented 5 years ago

Is fix coming? @bpasero https://www.youtube.com/watch?v=nDRBxtEUOFE

ci70 commented 4 years ago

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

matter123 commented 4 years ago

@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 commented 4 years ago

Open sqlite3 which is pretty large.

matter123 commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 3 years ago

It looks like the work in https://github.com/microsoft/vscode/issues/77140 may help solve this but Iā€™m not 100% sure

ebkgne commented 3 years ago

for me still not working here ...

Balrrach commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

Balrrach commented 2 years ago

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 commented 2 years ago

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 https://github.com/microsoft/vscode/issues/77140 it might be worth asking there. It looks to have gone dark.

ebkgne commented 2 years ago

@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 commented 2 years ago

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 commented 1 year ago

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 commented 7 months ago

Has anyone managed to fix this?

jasonwilliams commented 7 months ago

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: https://github.com/microsoft/vscode/issues/50140

RabiulAwalOvi commented 6 months ago

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)
func-void commented 3 months ago

how to fix this issue šŸ˜­, happened to me too

https://github.com/microsoft/vscode/assets/49369600/bf23e52b-7839-4461-8e47-532815cad1df

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

shubhamvermaa commented 3 months ago

Turn off enhanced colonization.

On Thu, Mar 28, 2024, 6:02 PM xhttp.res @.***> wrote:

how to fix this issue šŸ˜­, happened to me too

https://github.com/microsoft/vscode/assets/49369600/bf23e52b-7839-4461-8e47-532815cad1df

ā€” Reply to this email directly, view it on GitHub https://github.com/microsoft/vscode/issues/64681#issuecomment-2025076523, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXHBODQCNKZZF2AHCF4LTSDY2QEWBAVCNFSM4GJIENV2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMBSGUYDONRVGIZQ . You are receiving this because you commented.Message ID: @.***>

func-void commented 3 months ago

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

where ? i can't found it šŸ˜­

func-void commented 3 months ago

i'm work with javascript btw

shubhamvermaa commented 3 months ago

I am working with C++, and the option to disable enhanced colonization is available under the C/C++ extension.

On Thu, Mar 28, 2024, 6:32 PM xhttp.res @.***> wrote:

i'm work with javascript btw

ā€” Reply to this email directly, view it on GitHub https://github.com/microsoft/vscode/issues/64681#issuecomment-2025130354, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXHBODRGLWYCHHFBCCT7XTLY2QIFBAVCNFSM4GJIENV2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMBSGUYTGMBTGU2A . You are receiving this because you commented.Message ID: @.***>

shubhamvermaa commented 3 months ago

The issue for me started when I tweaked some token color parameter manually to customize the look of the code. If you just use the default color scheme or any theme extensions, without manually changing the token color then it may resolve the issue.

On Thu, Mar 28, 2024, 6:32 PM xhttp.res @.***> wrote:

i'm work with javascript btw

ā€” Reply to this email directly, view it on GitHub https://github.com/microsoft/vscode/issues/64681#issuecomment-2025130354, or unsubscribe https://github.com/notifications/unsubscribe-auth/AXHBODRGLWYCHHFBCCT7XTLY2QIFBAVCNFSM4GJIENV2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMBSGUYTGMBTGU2A . You are receiving this because you commented.Message ID: @.***>