★ wanayoo — archive 1999 https://github.com/PowerShell/PowerShellEditorServices/pull/1079Nouvelle recherche | Portail wanayoo
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 duplicate diagnostics caused by DidChange handler #1079

Merged
merged 3 commits into from Oct 31, 2019

Conversation

@TylerLeonhardt
Copy link
Member

@TylerLeonhardt TylerLeonhardt commented Oct 31, 2019

I discovered that duplicate diagnostics were being sent to vscode because we iterated through the ContentChanges and asked for diagnostics in that loop, even though, the changes pertained to the same file.

You can see the bug if you type really fast or use like the ## comment generator and stuff like that because it will include multiple ContentChanges to the same file in 1 textDocument/DidChange event.

This properly runs diagnostics after all code changes are applied.

Discovered this originally in #1078 (which has a similar change in it as well... thought it might affect us today and sure enough, it did!)

comes with a test too!

@TylerLeonhardt TylerLeonhardt requested a review from rjmholt as a code owner Oct 31, 2019
@TylerLeonhardt TylerLeonhardt changed the title Fix dup diagnostics Fix duplicate diagnostics caused by DidChange handler Oct 31, 2019
changedFile.ApplyChange(
GetFileChangeDetails(
textChange.Range,
textChange.Text));

changedFiles.Add(changedFile);

This comment has been minimized.

@rjmholt

rjmholt Oct 31, 2019
Member

Oh wow 🙄

@@ -145,6 +145,43 @@ public async Task CanReceiveDiagnosticsFromFileOpen()
Assert.Equal("PSUseDeclaredVarsMoreThanAssignments", diagnostic.Code);
}

[Fact]
public async Task CanReceiveDiagnosticsFromFileChanged()

This comment has been minimized.

@rjmholt

rjmholt Oct 31, 2019
Member

Nice!

@rjmholt rjmholt merged commit 2a7e8b6 into PowerShell:master Oct 31, 2019
7 of 8 checks passed
7 of 8 checks passed
Codacy/PR Quality Review Not up to standards. This pull request quality could be better.
Details
PowerShellEditorServices-CI Build #PR-1079-20191031.02 succeeded
Details
PowerShellEditorServices-CI (PowerShell 5.1 | Windows 10) PowerShell 5.1 | Windows 10 succeeded
Details
PowerShellEditorServices-CI (PowerShell 6 | Ubuntu) PowerShell 6 | Ubuntu succeeded
Details
PowerShellEditorServices-CI (PowerShell 6 | Windows 10) PowerShell 6 | Windows 10 succeeded
Details
PowerShellEditorServices-CI (PowerShell 6 | macOS) PowerShell 6 | macOS succeeded
Details
PowerShellEditorServices-secret-scan #PR-1079-20191031.02 succeeded
Details
license/cla All CLA requirements met.
Details
@TylerLeonhardt TylerLeonhardt deleted the TylerLeonhardt:fix-dup-diagnostics branch Oct 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.