public async Task HandleAsync(RequestHoverText command, KernelInvocationContext context) { var document = _workspace.ForkDocument(command.Code); var text = await document.GetTextAsync(); var cursorPosition = text.Lines.GetPosition(command.Position); var service = QuickInfoService.GetService(document); var info = await service.GetQuickInfoAsync(document, cursorPosition); if (info == null) { return; } var scriptSpanStart = text.Lines.GetLinePosition(0); var linePosSpan = text.Lines.GetLinePositionSpan(info.Span); var correctedLinePosSpan = linePosSpan.SubtractLineOffset(scriptSpanStart); context.PublishHoverTextMarkdownResponse(command, info.ToMarkdownString(), correctedLinePosSpan); }
public async Task HandleAsync(RequestHoverText command, KernelInvocationContext context) { var(document, offset) = GetDocumentWithOffsetFromCode(command.Code); var text = await document.GetTextAsync(); var cursorPosition = text.Lines.GetPosition(new LinePosition(command.Position.Line, command.Position.Character)); var absolutePosition = cursorPosition + offset; var service = QuickInfoService.GetService(document); var info = await service.GetQuickInfoAsync(document, absolutePosition); if (info == null) { return; } var scriptSpanStart = text.Lines.GetLinePosition(offset); var linePosSpan = text.Lines.GetLinePositionSpan(info.Span); var correctedLinePosSpan = linePosSpan.SubtractLineOffset(scriptSpanStart); context.PublishHoverTextMarkdownResponse(command, info.ToMarkdownString(), correctedLinePosSpan); }