nvim-dap icon indicating copy to clipboard operation
nvim-dap copied to clipboard

Add UI and API for ease of control over breakpoints

Open przepompownia opened this issue 3 years ago • 3 comments

Problem Statement

Currently the have two ways to centralized control all breakpoints: by running dap.clear_breakpoints() or dap.list_breakpoints(). The later allows for overview and jumping to the selected breakpoint.

Sometimes I would like to, for example, remove all except two breakpoints. It would be good to can remove some subset created by some selection or some API call (to utilize on dap-ui-like interfaces).

Ideas or possible solutions

From the UI point of view: mapping dd (or anything configurable) on a single quickfix item to remove breakpoint would be a significant step ahead.

przepompownia avatar Feb 21 '22 22:02 przepompownia

From the UI point of view: mapping dd (or anything configurable) on a single quickfix item to remove breakpoint would be a significant step ahead.

I'd kinda like that, but afaik it's currently not possible to have quickfix context specific mappings. It would probably need a dedicated widget and I currently don't plan to add that, unless adding support for data breakpoints or dependant breakpoints will make it necessary.

This might be something that fits more into https://github.com/rcarriga/nvim-dap-ui than the nvim-dap core.

mfussenegger avatar Jul 21 '22 09:07 mfussenegger

While browsing nvim-dap sources to try to make use of https://github.com/theHamsta/nvim-dap-virtual-text/pull/50 I found what toggle_breakpoint does in details. It seems that

require'dap.breakpoints'.remove(vim.api.nvim_buf_get_number(0), 22)
require 'dap'.session():set_breakpoints(require'dap.breakpoints'.get(vim.api.nvim_buf_get_number(0)))

is enough to remove breakpoint from the current buffer on line 22.

If it's correct, what do you think about adding explicit method to remove breakpoint by filename/bufnr and line?

przepompownia avatar Jan 20 '23 01:01 przepompownia

Just wanted to pitch in - I would love to extend the existing set_breakpoint API to take a custom filename and line number. This would be extremely useful in C++ projects if you want to set a breakpoint in external code. Perhaps we could combine setting and removing breakpoints by filename string? Note that I don't think adding UI elements belongs in this project - I would only like to make the API a bit more flexible.

@mfussenegger Thoughts?

hebaishi avatar Mar 11 '24 23:03 hebaishi