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

Adding quickfix.biome to editor.codeActionsOnSave slows down saving of *.ts files #232480

Open
mizdra opened this issue Oct 29, 2024 · 0 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug editor-code-actions Editor inplace actions (Ctrl + .) perf typescript Typescript support issues

Comments

@mizdra
Copy link

mizdra commented Oct 29, 2024

transferred from: microsoft/vscode-discussions#1664
ref: biomejs/biome-vscode#229

Does this issue occur when all extensions are disabled?: No. This issue occurs when typescript-language-features is enabled.

  • VS Code Version: 1.95.0-insider (Universal)
  • OS Version: Darwin arm64 24.0.0 / macOS 15.0.1

Background

The Biome VS Code extension guides users to add quickfix.biome to editor.codeActionsOnSave to fix issues when saving files.

However, enabling this setting causes saving *.ts files to be delayed by about 500ms.

368225325-56415cd5-d02e-4fd8-acc2-a5dcffb04932.mov

Surprisingly, this delay occurs even if the Biome extension is not installed. Additionally, disabling the built-in VS Code extension typescript-language-features eliminates the delay. For details of the issue and reproduction steps, please see the following comment:

Cause of the delay

As a result of my investigation, I found that the delay is caused by the following code in typescript-language-features:

When typescript-language-features receives a quickfix code action, it attempts to automatically fix some diagnostics. The execution process is as follows:

  1. Receive a quickfix code action.
  2. Check if there are diagnostics in the open file. If not, exit.
  3. Wait for 500ms.
  4. Retrieve diagnostics again.
  5. Automatically fix any fixable diagnostics obtained in step 4.

The 500ms wait is because the diagnostics obtained in step 2 might be outdated. If this wait time is removed, code fixes might be performed based on old diagnostics. To prevent this, typescript-language-features waits for 500ms.

Furthermore, typescript-language-features does not only respond to the quickfix code action. It responds to all code actions that start with quickfix, such as quickfix.biome and quickfix.some-name. Therefore, adding quickfix.biome to editor.codeActionsOnSave slows down the saving of *.ts files.

As an experiment, I commented out the line that waits for 500ms and rebuilt vscode, and the saving of *.ts files became faster.

2024-09-22.16.24.20.mov

Questions

I have several questions regarding this delay issue.

Q1. Is it acceptable to add quickfix or quickfix.biome to editor.codeActionsOnSave?

In the first place, does VS Code intend for quickfix or quickfix.biome to be added to editor.codeActionsOnSave? Neither quickfix nor quickfix.biome are included among the completion items for editor.codeActionsOnSave.

image

Is this because adding quickfix or quickfix.biome to editor.codeActionsOnSave is not intended? Should the Biome extension use source.fixAll.biome instead of quickfix.biome?

Q2. Is it okey for typescript-language-features to react to quickfix.biome?

This delay occurs because typescript-language-features is reacting to quickfix.biome. I feel that typescript-language-features is overly sensitive to code actions. Is this the intended behavior?

Should typescript-language-features be modified to react only to quickfix and quickfix.ts?

Q3. Is it okay that the source.fixAll.ts code action does not wait for 500ms?

In the quickfix code action, there is a 500ms wait, but in the source.fixAll.ts code action, this does not occur.

Therefore, in the source.fixAll.ts code action, there is a possibility that code fixes are performed based on old diagnostics. Is this the intended behavior?

@mjbvz mjbvz added typescript Typescript support issues editor-code-actions Editor inplace actions (Ctrl + .) bug Issue identified by VS Code Team member as probable bug perf labels Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug editor-code-actions Editor inplace actions (Ctrl + .) perf typescript Typescript support issues
Projects
None yet
Development

No branches or pull requests

2 participants