VSCodeVim / Vim

:star: Vim for Visual Studio Code
http://aka.ms/vscodevim
MIT License
13.97k stars 1.32k forks source link

Significant Performance Degradation on Large File #8115

Open pingshunhuangalex opened 1 year ago

pingshunhuangalex commented 1 year ago

Describe the bug I have a couple of 120k lines YAML files which I edit on a daily basis. With recent updates (in the past month or even a couple of weeks ago), VS Code has become so laggy that the letter needs to catch up when I type, and moving lines up and down becomes a nightmare. Keystrokes also get swallowed from time to time which makes things unusable.

Turning the extension off seems to fix the issue, but I really don't want to. Also please note that this was never a problem with VS Code Vim until recently. I can reproduce it on both Windows and Mac machines. Tried fresh reinstallation, but it doesn't do anything.

To Reproduce Steps to reproduce the behavior:

  1. Open a large file with let's say 120k
  2. Type quickly or try any basic line movement

Expected behavior There shouldn't be any lag for basic operations and typing

Screenshots With VS Code Vim ON

Nov-24-2022 10-46-34

With VS Code Vim OFF

Nov-24-2022 10-42-58

Environment (please complete the following information):

Version: 1.74.0-insider
Date: 2022-11-23T05:28:16.879Z
Electron: 19.1.3
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Darwin arm64 21.6.0
Sandboxed: Yes
VS Code Vim Version: v1.24.3
Arcitec commented 1 year ago

@pingshunhuangalex Interesting problem.

Have you tried this instead?

https://marketplace.visualstudio.com/items?itemName=asvetliakov.vscode-neovim

According to this article, it's much, much faster:

https://galenwong.github.io/blog/2021-03-22-vscode-neovim-vs-vscodevim/

And it uses native NeoVim, so there's no need to emulate Vim in JavaScript. It's all running natively with full support for all Vim commands.

Edit: The reason for VSCodeVim's slowness is because of how VSCode implements the JavaScript extension host. It's explained by a team member of VSCodeVim, who even recommended NeoVim as a solution:

https://github.com/VSCodeVim/Vim/issues/7546#issuecomment-1063674091

Someone even replied in that thread and said:

"I've just changed to vscode-neovim. Crazy fast."

Edit again: Here's someone who explains why the NeoVim extension is so much faster:

https://github.com/VSCodeVim/Vim/issues/7415#issuecomment-1019343700

In short, it seems to be because VSCodeVim has to register a type event handler in VSCode, which is a very slow action due to a problem in VSCode. Seems related to calling the default type handler from within a custom type handler. It also seems like something related to autocompletion is slowing things down further.

The NeoVim plugin doesn't do that. It unregisters the type handler while you write code, and sends all input to the NeoVim process instead. Then when you hit Escape to "return to VSCode" it re-registers the normal type handler. So there's no lag/delay at all, because VSCode's keyboard handler is "disabled" while you are writing code in NeoVim.

pingshunhuangalex commented 1 year ago

Thanks for the suggestion @Bananaman

I've hesitated before between the 2 options and picked VSCodeVim back then, probably cuz it's maintained by Microsoft devs.

I've accumulated quite a bit of configs and became reluctant to migrate. Maybe it's time to change now. Thanks.

Arcitec commented 1 year ago

@pingshunhuangalex Yeah I know the problem about having a lot of configs, but I think it's better to have a usable editor than a super laggy one. Slow text is so bad for productivity and peace of mind. :/

I heard so many good reviews for NeoVim plugin and will switch to it.

VSCodeVim isn't maintained by Microsoft by the way? At least if I look at the contributors, I can't find any Microsoft devs:

https://github.com/VSCodeVim/Vim/graphs/contributors

It's mainly maintained by https://github.com/J-Fields who works at another company.

Arcitec commented 1 year ago

@pingshunhuangalex Oh, I was thinking about this again and just realized that there may have been a misunderstanding.

I wasn't saying "switch to NeoVim". :D

The last one is what I said we should switch to:

https://marketplace.visualstudio.com/items?itemName=asvetliakov.vscode-neovim

MurtadhaInit commented 1 year ago

Thank you for the suggestion @Bananaman I didn't know such an extension existed. I'll give it a try. I came across this issue as the first thing I've noticed immediately after installing this plugin is the bizarre inconsistency even when navigating in normal mode.

Sometimes hitting the h key moves left, and sometimes it just decides not to do anything! Same thing when holding it: it either moves normally as expected, or just takes a moment then moves.

It's a shame. I really hope Microsoft works on a native Vim plugin, even if with a basic functionality. I think the Vim plugin in JetBrains IDEs is developed by JetBrains.

jvanheugten commented 1 year ago

I have the same issue but in a 6000 line Markdown file. Typing gets really slow with the VIM extension enabled (I had found this through the VSCode Bisection of plugins).