Skip to content

toggle_element silently closes all panels when given an unrecognised element name #82

@ooloth

Description

@ooloth

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

  1. Call toggle_element("nonexistent") — expect a notification or error message naming the bad input, and no panels are closed.
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions