From b4644cfc9f477023d1ce35e8c645c377c6302317 Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Sun, 12 Apr 2026 12:53:23 -0600 Subject: [PATCH] fix: borrow source-window context when continuing from a dapui pane MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The symptom: pressing c in dapui_scopes/watches/stacks/breakpoints/console printed "No configuration found for dapui_" because nvim-dap looks up dap.configurations[vim.bo.filetype] from the current window — and in dapui panes that filetype is dapui_* (no configs), not the source file's filetype. The modal key WAS firing; our smart_continue() ran but then ended up calling dap.continue() from the dapui pane's context, which blew up on config lookup. Fix: wrap the launch in run_in_source() which finds a window whose filetype isn't dapui_*/dap-repl/TurboDebugBar, then nvim_win_call()s into that window so nvim-dap reads the real source filetype (rust, python, go, etc.). Post-session dap.continue() resumes work as normal. Co-Authored-By: Claude Opus 4.6 (1M context) --- lua/turbo-debug/mode.lua | 41 +++++++++++++++++++++++++++++++++++----- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/lua/turbo-debug/mode.lua b/lua/turbo-debug/mode.lua index 1cb607d..c1ac812 100644 --- a/lua/turbo-debug/mode.lua +++ b/lua/turbo-debug/mode.lua @@ -568,6 +568,35 @@ local function has_any_breakpoint() return false end +-- Find a source window (non-dapui, non-repl, non-bar). nvim-dap reads the +-- current buffer's filetype to pick a launch configuration, so when the user +-- presses `c` while focused in a dapui pane (filetype=dapui_scopes, etc.), +-- we need to temporarily borrow a source window's context. +local function source_window() + -- prefer the current window if it's a source + local cur = vim.api.nvim_get_current_win() + local function is_source(w) + if not vim.api.nvim_win_is_valid(w) then return false end + if vim.api.nvim_win_get_config(w).relative ~= "" then return false end + local ft = vim.bo[vim.api.nvim_win_get_buf(w)].filetype or "" + return ft ~= "" + and not ft:match("^dapui_") + and ft ~= "dap-repl" + and ft ~= "TurboDebugBar" + end + if is_source(cur) then return cur end + for _, w in ipairs(vim.api.nvim_list_wins()) do + if is_source(w) then return w end + end + return nil +end + +local function run_in_source(fn) + local w = source_window() + if w then return vim.api.nvim_win_call(w, fn) end + return fn() +end + local function launch_with_stop_on_entry() local dap = require("dap") local ft = vim.bo.filetype or "" @@ -585,11 +614,13 @@ end local function smart_continue() local dap = require("dap") if dap.session() then dap.continue(); return end - if config.opts.stop_on_entry_when_no_breakpoints ~= false and not has_any_breakpoint() then - launch_with_stop_on_entry() - else - dap.continue() - end + run_in_source(function() + if config.opts.stop_on_entry_when_no_breakpoints ~= false and not has_any_breakpoint() then + launch_with_stop_on_entry() + else + dap.continue() + end + end) end local function step_or_launch(step_fn)