コード例 #1
0
        private void HandlePromptResponse(
            Task <ShowInputPromptResponse> responseTask)
        {
            if (responseTask.IsCompleted)
            {
                ShowInputPromptResponse response = responseTask.Result;

                if (!response.PromptCancelled)
                {
                    this.consoleService.ReceivePromptResponse(
                        response.ResponseText,
                        true);
                }
                else
                {
                    // Cancel the current prompt
                    this.consoleService.SendControlC();
                }
            }
            else
            {
                if (responseTask.IsFaulted)
                {
                    // Log the error
                    Logger.Write(
                        LogLevel.Error,
                        "ShowInputPrompt request failed with error:\r\n{0}",
                        responseTask.Exception.ToString());
                }

                // Cancel the current prompt
                this.consoleService.SendControlC();
            }
        }
コード例 #2
0
        public async Task <string> PromptInputAsync(string message)
        {
            // The VSCode client currently doesn't use the Label field, so we ignore it
            ShowInputPromptResponse response = await _languageServer.SendRequest <ShowInputPromptRequest>(
                "powerShell/showInputPrompt",
                new ShowInputPromptRequest
            {
                Name = message,
            }).Returning <ShowInputPromptResponse>(CancellationToken.None);

            if (response.PromptCancelled)
            {
                return(null);
            }

            return(response.ResponseText);
        }
コード例 #3
0
        private void HandlePromptResponse(
            Task <ShowInputPromptResponse> responseTask)
        {
            if (responseTask.IsCompleted)
            {
                ShowInputPromptResponse response = responseTask.Result;

                if (!response.PromptCancelled)
                {
                    this.hostOutput.WriteOutput(
                        response.ResponseText,
                        OutputType.Normal);

                    this.readLineTask.TrySetResult(response.ResponseText);
                }
                else
                {
                    // Cancel the current prompt
                    this.hostInput.SendControlC();
                }
            }
            else
            {
                if (responseTask.IsFaulted)
                {
                    // Log the error
                    Logger.Write(
                        LogLevel.Error,
                        "ShowInputPrompt request failed with error:\r\n{0}",
                        responseTask.Exception.ToString());
                }

                // Cancel the current prompt
                this.hostInput.SendControlC();
            }

            this.readLineTask = null;
        }