Skip to content

Add ShowMessageRequest API to psEditor #1111

Open
@SeeminglyScience

Description

@SeeminglyScience

Right now we have the send message notifications hooked up, but there's also a request that looks like this:

image

It would be cool to have that hooked up in a generally accessible way. Right now you can do this:

using namespace OmniSharp.Extensions.LanguageServer.Protocol.Models
using namespace OmniSharp.Extensions.LanguageServer.Protocol.Server
using namespace OmniSharp.Extensions.LanguageServer.Server


# Type name is fully qualified because there's an ILanguageServer
# in both the Protocol and the Server namespaces.
$server = $psEditor.Components.GetService(
    [OmniSharp.Extensions.LanguageServer.Protocol.Server.ILanguageServer])

$task = [ShowMessageRequestExtensions]::Request(
    $server.Window,
    [ShowMessageRequestParams]@{
        Type = [MessageType]::Error
        Message = 'Question that is relevant to the options?'
        Actions = (
            [MessageActionItem]@{ Title = 'Option 1' },
            [MessageActionItem]@{ Title = 'Option 2' })
    })

while (-not $task.AsyncWaitHandle.WaitOne(200)) { }

# This will hold the chosen MessageActionItem
$result = $task.GetAwaiter().GetResult()

Something like this would be great though:

public partial class EditorWindow
{
    public string SendMessage(
        MessageType messageType,
        string caption,
        params string[] options);
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions