mfussenegger / nvim-dap

Debug Adapter Protocol client implementation for Neovim
GNU General Public License v3.0
5.47k stars 194 forks source link

require'dap.utils'.pick_process does not work with filter name #1015

Closed codeprefect closed 1 year ago

codeprefect commented 1 year ago

Debug adapter definition and debug configuration

dap.adapters = {                 
  coreclr = {
    args = { "--interpreter=vscode" },
    command = "/Users/***/.local/share/nvim/mason/bin/netcoredbg",
    type = "executable"
  },
}

dap.configurations = {
    cs = {
    {
      name = "Attach to process (DAP)",
      processId = require'dap.utils'.pick_process { filter = "AppName" },
      request = "attach",
      type = "coreclr"
    }
}

Debug adapter version

No response

Steps to Reproduce

Start a .NET Core project from the command line Modify the name in the configuration filter to match the app name Start dap and choose "Attach to process (DAP)" Picker shows a list of matching processes (usually 1 if the name is an exact match)

Expected Result

Debugger is attached to running application

Actual Result

Dap fails to attach debugger.

NOTE: The same exact configuration works if the filter is removed.

mfussenegger commented 1 year ago

You're calling the function eagerly on definition. You need to call it on use

dap.configurations.cs = {
    {
      name = "Attach to process (DAP)",
      processId = function() return require'dap.utils'.pick_process { filter = "AppName" } end,
      request = "attach",
      type = "coreclr"
    },
}
codeprefect commented 1 year ago

My bad, I had a casing typo in the AppName, hence the error. Thank you.