volarjs / volar.js

💙🌊
https://volarjs.dev/
MIT License
970 stars 47 forks source link

fix(language-service): fix caching of semantic diagnostics #141

Closed remcohaszing closed 6 months ago

remcohaszing commented 6 months ago

This fixes a caching issue regarding semanric diagnostics. I don’t fully understand why. Returning an empty array from https://github.com/mdx-js/mdx-analyzer/blob/f6a43853d5ae0509b93001fdf6f58e1466106605/packages/language-service/lib/service-plugin.js#L163 fixed the issue, so I figured this was an upstream problem in Volar.

Refs https://github.com/mdx-js/mdx-analyzer/issues/400

johnsoncodehk commented 6 months ago

LGTM, thanks!

The reason is that when the service returns undefined result, the following lines cannot replace the response cache.

https://github.com/volarjs/volar.js/blob/74b3600c03c0ce28bfd98d860e56578d4b762246/packages/language-service/lib/features/provideDiagnostics.ts#L284-L287