Skip to content

How to programmatically remove a breakpoint from active session? #1187

Closed Answered by ibhagwan
ibhagwan asked this question in Q&A
Discussion options

You must be logged in to vote

Oh well, that didn't take long I answered myself :-)

Turns out that if I delete the last bp in a buffer I must set the bp[index] = {} in order to clear all breakpionts, my latest working code:

M.dap_bp_del = function(selected, opts)
  local bufnrs = {}
  local dap_bps = require("dap.breakpoints")
  for _, e in ipairs(selected) do
    local entry = path.entry_to_file(e, opts)
    if entry.bufnr > 0 and entry.line then
      dap_bps.remove(entry.bufnr, entry.line)
      table.insert(bufnrs, tonumber(entry.bufnr))
    end
  end
  -- removing the BP will update the UI, if we're in session
  -- we also need to broadcast the BP delete to the DAP server
  local session = require("dap").session()
  

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by ibhagwan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant