From 7f58da606e28fe7877862a58c363a1af3347f51e Mon Sep 17 00:00:00 2001 From: Andy Jordan <2226434+andyleejordan@users.noreply.github.com> Date: Tue, 17 Oct 2023 17:20:12 -0700 Subject: [PATCH] Ignore `didOpen` notifications for `git` schemed documents from VS Code For some reason VS Code, in some repositories and configurations, will send us `DidOpenTextDocument` notifications for special documents with the `git` scheme (not `file` or `untitled`). It's probably some internal representation that VS Code is using to supply VCS information. Because we were specifically ignoring the URI in this handler these files were getting erroneously added to our workspace service's list of open files, which then caused duplicate references. --- .../Services/TextDocument/Handlers/TextDocumentHandler.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/TextDocumentHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/TextDocumentHandler.cs index 79af825ed..a02e7b884 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/TextDocumentHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/TextDocumentHandler.cs @@ -74,6 +74,14 @@ protected override TextDocumentSyncRegistrationOptions CreateRegistrationOptions public override Task Handle(DidOpenTextDocumentParams notification, CancellationToken token) { + // We're receiving notifications for special "git" scheme files from VS Code, and we + // need to ignore those! Otherwise they're added to our workspace service's opened files + // and cause duplicate references. + if (notification.TextDocument.Uri.Scheme == "git") + { + return Unit.Task; + } + // We use a fake Uri because we only want to test the LanguageId here and not if the // file ends in ps*1. TextDocumentAttributes attributes = new(s_fakeUri, notification.TextDocument.LanguageId);