Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions doc/dap.txt
Original file line number Diff line number Diff line change
Expand Up @@ -592,11 +592,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'
nvim-dap provides an additional `usevisible`
(`tabusevisible`) option that can be used to prevent
jumps within the active window (tab) 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.
Expand Down
14 changes: 14 additions & 0 deletions lua/dap/session.lua
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,7 @@ local function jump_to_location(bufnr, line, column, switchbuf, filetype)
end

local cur_win = api.nvim_get_current_win()
local cur_tab = api.nvim_win_get_tabpage(cur_win)
local switchbuf_fn = {}

function switchbuf_fn.uselast()
Expand Down Expand Up @@ -456,6 +457,19 @@ local function jump_to_location(bufnr, line, column, switchbuf, filetype)
return false
end

function switchbuf_fn.tabusevisible()
for _, win in ipairs(vim.api.nvim_tabpage_list_wins(cur_tab)) do
if api.nvim_win_get_buf(win) == bufnr then
local first = vim.fn.line("w0", win)
local last = vim.fn.line("w$", win)
if first <= line and line <= last then
return true
end
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)
Expand Down