sveltejs / language-tools

The Svelte Language Server, and official extensions which use it
MIT License
1.2k stars 195 forks source link

Options to change Intellisense check delay #1132

Open SuspiciousLookingOwl opened 3 years ago

SuspiciousLookingOwl commented 3 years ago

Is your feature request related to a problem? Please describe. Svelte extension in VSCode seems to have 1 second debounce delay between checking svelte-vscode

Compared to TypeScript which is around 500ms ts-vscode

for some developer 1s delay is too long or doesn't feel responsive

Describe the solution you'd like It would be nice to be able to change the debounce value to provide more responsive checking for developer with beefier machine

Additional context I'm using Svelte VSCode v105.3.4 and those are my devDependencies (default from npm init svelte@next my-app with TS + Eslint + Prettier)

{
  "@sveltejs/kit": "next",
  "@typescript-eslint/eslint-plugin": "^4.19.0",
  "@typescript-eslint/parser": "^4.19.0",
  "eslint": "^7.22.0",
  "eslint-config-prettier": "^8.1.0",
  "eslint-plugin-svelte3": "^3.2.0",
  "prettier": "~2.2.1",
  "prettier-plugin-svelte": "^2.2.0",
  "svelte": "^3.34.0",
  "svelte-check": "^2.0.0",
  "svelte-preprocess": "^4.0.0",
  "tslib": "^2.0.0",
  "typescript": "^4.0.0"
}
dummdidumm commented 3 years ago

The diagnostics delay is purposefully higher than for TS. The reason is that TS is able to cancel the compution of diagnostics if keystroke is registered. This is private API however, which we have no access to, so we can't cancel this potentially heavy computation. We added some smarter debounce handling since that decision however, so we might as well try how it performs now when lowering the delay a little. I'm very hesitant to make this configurable.

dummdidumm commented 2 years ago

The intellisense was lowered to 750 miliseconds delay. Please let me know if this is better for you now.

SuspiciousLookingOwl commented 2 years ago

It feels better, but is there any reason why you're hesitant to make this configurable? I think it's nice to have an option for developers with beefier PC to experience more responsive diagnostic.

Edit: after short look at the source code, my guess is it's not as straightforward to implement

It's okay to set the default value to 1000ms, but please make this configurable.


If you wanna try to experience more responsive diagnostic result, you can edit the extension source code manually by following these steps (make sure you have Svelte for VS Code extension installed on your VS Code):

  1. Open the VSCode extension installation folder

    Windows %USERPROFILE%\.vscode\extensions macOS ~/.vscode/extensions Linux ~/.vscode/extensions

  2. Open svelte.svelte-vscode-xxx.x.x\node_modules\svelte-language-server\dist\src\server.js
  3. Search for this line:
    docManager.on('documentChange', utils_1.debounceThrottle(async (document) => diagnosticsManager.update(document), 750));

    and modify the debounce delay (750) to whichever you like.

  4. Save the file, then make sure you reloaded your VSCode windows.

I wouldn't say I recommend you to do this, but if you really want to have more responsive diagnostic result, the above steps works.

I set mine to 500 and it feels much better. 350 feels amazing but I think 500 should be fine for most people.