Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix cursor lag in VS Code?

I set the editor.cursorSmoothCaretAnimation to true in Visual Studio Code but the cursor lags behind when I type/select/delete text quickly:

enter image description here

I turned off all the extensions in VS Code by running code --disable-extensions in terminal but the problem persists.

How can this be fixed?

like image 262
TheLastAirbender Avatar asked Oct 14 '22 23:10

TheLastAirbender


1 Answers

I Found a Solution

tl;dr: I had set editor.smoothScrolling to true. Disabling that option (mostly) solved the issue:

enter image description here

The cursor does not stutter as much in person as it might look like it does in this gif. There is still a little bit of lag - about 1 to 1.5 characters, but not more than that. This is actually the same amount of lag I was seeing when every extension was disabled and all settings except editor.cursorSmoothCaretAnimation were commented out, which tells me that the lag can't be reduced any further (or at least I can't reduce it any further).

So how did I arrive at this solution?

Initially, I had disabled extensions temporarily by running code --disable-extensions in terminal but that didn't seem to solve the problem. So, I went ahead and manually disabled each extension (globally) and also commented out all my settings in the settings.json file, except editor.cursorSmoothCaretAnimation. Thankfully, I found that the cursor lag had reduced to about 1 to 1.5 characters. As disabling all the extensions had not solved the issue before, I had an inkling that my settings were to blame for the lag. Thus, I began going through each setting and began uncommenting them, one by one, and checking to see if the lag had returned. Finally, I found that uncommenting the editor.smoothScrolling setting reintroduced the bothersome lag. Hoping that that setting was the only one causing it, I uncommented all of the other settings and enabled all my extensions. To my surprise, the lag did not increase any further. Later on, I did a few checks and I can confirm that editor.smoothScrolling is the setting to blame for this.

Why?

Why this happens, I do not know. I will be opening a new issue about it in the VS Code Github.

like image 158
TheLastAirbender Avatar answered Oct 19 '22 00:10

TheLastAirbender