mirror of
https://github.com/mfussenegger/nvim-dap
synced 2024-09-16 14:24:03 +02:00
Add a usevisible
switchbuf option
Closes https://github.com/mfussenegger/nvim-dap/issues/1328
This commit is contained in:
parent
281a2e4cd1
commit
20a4859ebd
2 changed files with 17 additions and 0 deletions
|
@ -580,6 +580,12 @@ The configuration values are set via `dap.defaults.fallback` (for global) or
|
|||
See |'switchbuf'|. Defaults to the global `'switchbuf'`
|
||||
setting.
|
||||
|
||||
nvim-dap provides an additional `usevisible` option
|
||||
that can be used to prevent jumps within the active
|
||||
window if a stopped event is within the visible region.
|
||||
Best used in combination with other options. For
|
||||
example: 'usevisible,usetab,uselast'
|
||||
|
||||
- `on_output`. A function with two parameters: `session` and `output_event`:
|
||||
Overrides the default output handling with a custom handler.
|
||||
|
||||
|
|
|
@ -433,6 +433,17 @@ local function jump_to_location(bufnr, line, column, switchbuf, filetype)
|
|||
return true
|
||||
end
|
||||
|
||||
function switchbuf_fn.usevisible()
|
||||
if api.nvim_win_get_buf(cur_win) == bufnr then
|
||||
local first = vim.fn.line("w0", cur_win)
|
||||
local last = vim.fn.line("w$", cur_win)
|
||||
if first <= line and line <= last then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function switchbuf_fn.useopen()
|
||||
if api.nvim_win_get_buf(cur_win) == bufnr then
|
||||
set_cursor(cur_win, line, column)
|
||||
|
|
Loading…
Reference in a new issue