Skip to content

Commit 6d9218e

Browse files
Kapil Borledaviwil
Kapil Borle
authored andcommitted
Update DidOpenTextDocumentNotification
1 parent 5ba3d59 commit 6d9218e

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

src/PowerShellEditorServices.Protocol/LanguageServer/TextDocument.cs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,22 @@ public class TextDocumentPositionParams {
9494
public Position Position { get; set; }
9595
}
9696

97-
public class DidOpenTextDocumentNotification : TextDocumentIdentifier
97+
public class DidOpenTextDocumentNotification
9898
{
9999
public static readonly
100-
EventType<TextDocumentItem> Type =
101-
EventType<TextDocumentItem>.Create("textDocument/didOpen");
100+
EventType<DidOpenTextDocumentParams> Type =
101+
EventType<DidOpenTextDocumentParams>.Create("textDocument/didOpen");
102+
}
102103

104+
/// <summary>
105+
/// The parameters sent in an open text document notification
106+
/// </summary>
107+
public class DidOpenTextDocumentParams
108+
{
103109
/// <summary>
104-
/// Gets or sets the full content of the opened document.
110+
/// The document that was opened.
105111
/// </summary>
106-
public string Text { get; set; }
112+
public TextDocumentItem TextDocument { get; set; }
107113
}
108114

109115
public class DidCloseTextDocumentNotification

src/PowerShellEditorServices.Protocol/Server/LanguageServer.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,13 +483,13 @@ private async Task HandleFindModuleRequest(
483483
}
484484

485485
protected Task HandleDidOpenTextDocumentNotification(
486-
TextDocumentItem openParams,
486+
DidOpenTextDocumentParams openParams,
487487
EventContext eventContext)
488488
{
489489
ScriptFile openedFile =
490490
editorSession.Workspace.GetFileBuffer(
491-
openParams.Uri,
492-
openParams.Text);
491+
openParams.TextDocument.Uri,
492+
openParams.TextDocument.Text);
493493

494494
// TODO: Get all recently edited files in the workspace
495495
this.RunScriptDiagnostics(

test/PowerShellEditorServices.Test.Host/LanguageServerTests.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -752,13 +752,16 @@ private async Task SendOpenFileEvent(string filePath, bool waitForDiagnostics =
752752

753753
await this.SendEvent(
754754
DidOpenTextDocumentNotification.Type,
755-
new TextDocumentItem()
755+
new DidOpenTextDocumentParams
756756
{
757-
Uri = filePath,
758-
Text = fileContents,
759-
LanguageId = "PowerShell",
760-
Version = 0
761-
});
757+
TextDocument = new TextDocumentItem
758+
{
759+
Uri = filePath,
760+
Text = fileContents,
761+
LanguageId = "PowerShell",
762+
Version = 0
763+
}
764+
});
762765

763766
if (diagnosticWaitTask != null)
764767
{

0 commit comments

Comments
 (0)