From 9f6d831df0ca2d57ca608e04de51731e0922265c Mon Sep 17 00:00:00 2001 From: "Samuel D. Leslie" Date: Sat, 20 Jun 2020 11:36:53 +1000 Subject: [PATCH] Return null when Hover request is cancelled or no symbol details Previously we returned a new Hover instance without initializing the Contents or Range members. At least in VS Code, this will result in the LSP client attempting to access null properties. As we're not returning any Hover data, the correct response is to simply return null. --- .../Services/TextDocument/Handlers/HoverHandler.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/PowerShellEditorServices/Services/TextDocument/Handlers/HoverHandler.cs b/src/PowerShellEditorServices/Services/TextDocument/Handlers/HoverHandler.cs index ad2174487..6f2c83d79 100644 --- a/src/PowerShellEditorServices/Services/TextDocument/Handlers/HoverHandler.cs +++ b/src/PowerShellEditorServices/Services/TextDocument/Handlers/HoverHandler.cs @@ -48,7 +48,7 @@ public async Task Handle(HoverParams request, CancellationToken cancellat if (cancellationToken.IsCancellationRequested) { _logger.LogDebug("Hover request canceled for file: {0}", request.TextDocument.Uri); - return new Hover(); + return null; } ScriptFile scriptFile = _workspaceService.GetFile(request.TextDocument.Uri); @@ -61,7 +61,7 @@ await _symbolsService.FindSymbolDetailsAtLocationAsync( if (symbolDetails == null) { - return new Hover(); + return null; } List symbolInfo = new List();