Why
toggle_element iterates over layouts_index_by_element to find a matching element, but if the given name is not a key, the loop closes every panel and opens none — a silent no-op failure that gives the developer no diagnostic.
Current state
lua/config/plugins/specs/nvim-dap.lua lines 39–63: local function toggle_element(element) — no assertion or early return checks that element is a recognised key in layouts_index_by_element before the loop runs. An unrecognised element name causes the loop to exhaust all entries, closing each panel, and the function returns silently.
Ideal state
toggle_element asserts (via vim.notify with an error level, or an early return) that element is a recognised key before entering the loop.
- An unrecognised element name produces a visible message instead of silently closing all panels.
Starting points
lua/config/plugins/specs/nvim-dap.lua — lines 39–63, the toggle_element function and the layouts_index_by_element table it reads
QA plan
- Call
toggle_element("nonexistent") — expect a notification or error message naming the bad input, and no panels are closed.
- Call
toggle_element with a valid element name — expect normal toggle behaviour unchanged.
Done when
Passing an unrecognised element name to toggle_element produces a visible diagnostic instead of silently closing all open DAP UI panels.
Why
toggle_elementiterates overlayouts_index_by_elementto find a matching element, but if the given name is not a key, the loop closes every panel and opens none — a silent no-op failure that gives the developer no diagnostic.Current state
lua/config/plugins/specs/nvim-dap.lualines 39–63:local function toggle_element(element)— no assertion or early return checks thatelementis a recognised key inlayouts_index_by_elementbefore the loop runs. An unrecognised element name causes the loop to exhaust all entries, closing each panel, and the function returns silently.Ideal state
toggle_elementasserts (viavim.notifywith an error level, or an early return) thatelementis a recognised key before entering the loop.Starting points
lua/config/plugins/specs/nvim-dap.lua— lines 39–63, thetoggle_elementfunction and thelayouts_index_by_elementtable it readsQA plan
toggle_element("nonexistent")— expect a notification or error message naming the bad input, and no panels are closed.toggle_elementwith a valid element name — expect normal toggle behaviour unchanged.Done when
Passing an unrecognised element name to
toggle_elementproduces a visible diagnostic instead of silently closing all open DAP UI panels.