Skip to content

Commit b82b8b8

Browse files
committed
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.
1 parent d052a50 commit b82b8b8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/PowerShellEditorServices/Services/TextDocument/Handlers/TextDocumentHandler.cs

+8
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ protected override TextDocumentSyncRegistrationOptions CreateRegistrationOptions
7474

7575
public override Task<Unit> Handle(DidOpenTextDocumentParams notification, CancellationToken token)
7676
{
77+
// We're receiving notifications for special "git" scheme files from VS Code, and we
78+
// need to ignore those! Otherwise they're added to our workspace service's opened files
79+
// and cause duplicate references.
80+
if (notification.TextDocument.Uri.Scheme == "git")
81+
{
82+
return Unit.Task;
83+
}
84+
7785
// We use a fake Uri because we only want to test the LanguageId here and not if the
7886
// file ends in ps*1.
7987
TextDocumentAttributes attributes = new(s_fakeUri, notification.TextDocument.LanguageId);

0 commit comments

Comments
 (0)