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

Fix folder deletion with VSCode #1821

Merged

Conversation

savpek
Copy link
Contributor

@savpek savpek commented Jun 5, 2020

VSCode has issue (however by design at current version) where removed folders doesn't send any notifications of removed files because file watcher has some kind of performance optimizations to ignore them.

However watching folders removal is possible. This PR adds support for omnishar-roslyn side so clients can notify removed directory instead of single files if needed -> which can be impelemented properly with current VSCode file watcher.

This fixes one of most common issue that requires omnisharp restart on any directory rename/move/... operation.

Vscode side implementation: dotnet/vscode-csharp#3829

@savpek savpek marked this pull request as ready for review June 5, 2020 14:47
@savpek
Copy link
Contributor Author

savpek commented Jun 5, 2020

Ready for review @filipw @JoeRobich @david-driscoll

Copy link
Member

@JoeRobich JoeRobich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -18,6 +20,16 @@ public void Notify(string filePath, FileChangeType changeType = FileChangeType.U
{
lock (_gate)
{
if(changeType == FileChangeType.DirectoryDelete)
{
foreach(var matchingCallback in _callbacksMap.AsEnumerable().Where(x => x.Key.StartsWith(filePath + Path.DirectorySeparatorChar, StringComparison.OrdinalIgnoreCase)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't this going to end up calling OnDocumentRemoved twice on a file? once from here as a file and then again through the directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, i will remove that part as it's unnecessary.

Original idea were to hide directory removal specifics from subscribers of file watcher, however since it uses other than full paths (extensions etc) too it were not possible and this was left behind from that version.

Removed at e90ea72

Copy link
Member

@filipw filipw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very good change - thanks

@filipw filipw merged commit 2e1b1c0 into OmniSharp:master Jun 6, 2020
bjorkstromm added a commit that referenced this pull request Jun 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants