-
Notifications
You must be signed in to change notification settings - Fork 185
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
Ensure diagnostics are cleared on file deletion #319
Ensure diagnostics are cleared on file deletion #319
Conversation
Previously, error diagnostics would not be cleared when a file was deleted while it was closed. This would result in lingering errors in the problems view that could only be cleared by reloading the language server. This fix addresses the issue by adding support for workspace/didChangeWatchedFiles and automatically clearing diagnostics for deleted files.
Codecov Report
@@ Coverage Diff @@
## master #319 +/- ##
============================================
- Coverage 85.98% 84.15% -1.83%
- Complexity 717 811 +94
============================================
Files 53 59 +6
Lines 1463 1717 +254
============================================
+ Hits 1258 1445 +187
- Misses 205 272 +67
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Implementing didChangeWatchedFiles
was on my todo for a long time.
Especially adding or changing a file should cause a (re)index of the file, for example on a branch switch.
Regarding the tests, I think the best would be to use a mocking library like prophecy to mock the LanguageClient
and assert that publishDiagnostics
was called. I tried that once but failed to get it working so I just went with listening for the message
event in the other tests, which works.
Just the code style change to merge this
|
||
$fileEvent = new FileEvent(); | ||
$fileEvent->uri = 'my uri'; | ||
$fileEvent->type = FileChangeType::DELETED; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense to add a constructor to FileEvent
to make this easier to construct
$fileEvent->type = FileChangeType::DELETED; | ||
|
||
$isDiagnosticsCleared = false; | ||
$writer->on('message', function (Message $message) use ($fileEvent, & $isDiagnosticsCleared) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No space after &
Done, thanks for the feedback! Also made the corresponding PR at felixfbecker/vscode-php-intellisense#83. And with that, I'm off to bed because it's 2am here. 💤 |
Previously, error diagnostics would not be cleared when a file was deleted while it was closed. This would result in lingering errors in the problems view that could only be cleared by reloading the language server. This fix addresses the issue by adding support for workspace/didChangeWatchedFiles and automatically clearing diagnostics for deleted files.
Additional Notes / Questions