Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing output stream when debugging from neovim #2119

Closed
2 tasks done
Willem-J-an opened this issue Dec 21, 2023 · 6 comments
Closed
2 tasks done

Missing output stream when debugging from neovim #2119

Willem-J-an opened this issue Dec 21, 2023 · 6 comments
Labels
Issue-Enhancement A feature request (enhancement). Needs: Triage Maintainer attention needed!

Comments

@Willem-J-an
Copy link
Contributor

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all issues to ensure it has not already been requested.

Summary

I'm trying to integrate neovim DAP client with powershell. Recently support was added for named pipes in the client, so I got to work and got the integration working. I can launch the debugger, use breakpoints, step through, evaluate expressions, all good.

The only problem is: I don't seem to get the output stream of the actual script. No output when I simply run the script, and neither on the repl. The only way to get output is using the evaluating expressions or watching expressions. The integration is working to some extent; for example I can do $x = 'a' in the repl, and if I watch $x it will show 'a'. Is there any obvious reason from the perspective of my configuration that could explain this behaviour?

            local PSES_BUNDLE_PATH = vim.fn.expand("~/.local/share/nvim/mason/packages/powershell-editor-services")
            local tmpdir = os.tmpname() .. "d"
            os.execute("mkdir " .. tmpdir)
            dap.adapters.ps1 = {
                type = "pipe",
                pipe = "${pipe}",
                executable = {
                    command = "pwsh",
                    args = {
                        "-NoLogo",
                        "-NoProfile",
                        "-NonInteractive",
                        "-OutputFormat",
                        "Text",
                        "-File",
                        PSES_BUNDLE_PATH .. "/PowerShellEditorServices/Start-EditorServices.ps1",
                        "-BundledModulesPath",
                        PSES_BUNDLE_PATH,
                        "-LogPath",
                        tmpdir .. "/logs.log",
                        "-SessionDetailsPath",
                        tmpdir .. "/session.json",
                        "-HostName",
                        "Neovim",
                        "-HostProfileId",
                        "Neovim.DAP",
                        "-HostVersion",
                        "1.0.0",
                        "-LogLevel",
                        "Normal",
                        "-DebugServiceOnly",
                        "-DebugServicePipeName",
                        "${pipe}"
                    },
                },
            }
            require("dap.ext.vscode").load_launchjs()
// launch.json object
{
            "name": "PowerShell: Current",
            "type": "ps1",
            "request": "launch",
            "script": "${file}",
            "cwd": "${file}",
            //"createTemporaryIntegratedConsole": true // Does not really change the behaviour
        }

Proposed Design

No response

@Willem-J-an Willem-J-an added Issue-Enhancement A feature request (enhancement). Needs: Triage Maintainer attention needed! labels Dec 21, 2023
@andyleejordan
Copy link
Member

I wonder if this is related to what @dkattan was seeing (and fixing) in #2122.

@Willem-J-an
Copy link
Contributor Author

Could be related indeed. If I pass the -EnableConsoleRepl switch everything crashes and burns so I'm not passing that flag. Would that cause suppression of output though pses dap?

@Willem-J-an
Copy link
Contributor Author

Hi @andyleejordan,

Getting back to doing some powershell debugging; seems like some improvements were made on the above topics!
I can see stdout and stderr output now:

[debug-adapter stdout] Using context;

[debug-adapter stderr] �[31;1mNew-AzResourceGroupDeployment: �[0mdeploy_workbooks.ps1:49�[0m
�[31;1m�[0m�[36;1mLine |�[0m
�[31;1m�[0m�[36;1m�[36;1m  49 | �[0m     �[36;1mNew-AzResourceGroupDeployment `�[0m
�[31;1m�[0m�[36;1m�[36;1m�[0m�[36;1m�[0m�[36;1m     | �[31;1m     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~�[0m

Unfortunately, the colors codes are not interpreted on neovim dap client. Is there a way to disable the color codes, or would you have any other suggestions how to deal with this ?

Thanks!

@Willem-J-an
Copy link
Contributor Author

For posterity: I found a way to make it work using Baleia:

{
        "m00qek/baleia.nvim",
        tag = "v1.4.0",
        config = function()
            local baleia = require("baleia").setup()
            vim.api.nvim_create_user_command("Baleia", function()
                baleia.automatically(vim.fn.bufnr("%"))
            end, {})
        end,
    }

image

@andyleejordan
Copy link
Member

Awesome news, thanks for sharing!!!

@andyleejordan
Copy link
Member

I think you could try:

$PSStyle.OutputRendering = [System.Management.Automation.OutputRendering]::PlainText;

to disable the color codes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Enhancement A feature request (enhancement). Needs: Triage Maintainer attention needed!
Projects
None yet
Development

No branches or pull requests

2 participants