volarjs / services

MIT License
124 stars 25 forks source link

When opening a huge d.ts file, there will be long periods of high CPU usage. #62

Closed skywalker512 closed 1 month ago

skywalker512 commented 8 months ago

When I use https://github.com/alex8088/electron-vite to create an Electron Vue project, (pnpm create @quick-start/electron). Whenever I open electron.d.ts, I observe that volar ls has a long 100% CPU usage, during which ls does not respond to other operations.

image

CPU-20231031T215046.cpuprofile

I am not very familiar with vscode, ts, lsp. I observed using the Chrome performance panel and found that it occupies a lot of time here.

https://github.com/volarjs/services/blob/v0.0.16/packages/typescript/src/features/codeAction.ts#L102

It was introduced in https://github.com/volarjs/services/pull/29

I looked up the implementation of the vscode ts plugin and found that it does not invoke getEditsForRefactor in provideCodeActions. (I am not very familiar with vscode) https://github.com/microsoft/vscode/blob/1.83.1/extensions/typescript-language-features/src/languageFeatures/refactor.ts#L487

skywalker512 commented 8 months ago

At the same time, I also found that if I use version 5.1.6 of Typescript, there is no such issue (VSCode will not display the light bulb icon).

skywalker512 commented 6 months ago

In volar 2.0, there shouldn't be this issue.