Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[BUG] toggle stops working after edit on dap windows (repl included) #325

Closed
serranomorante opened this issue Jan 27, 2024 · 1 comment
Closed

Comments

@serranomorante
Copy link
Contributor

2024-01-27.22-52-24.mp4

Pressing e keymap to edit a variable breaks the toggle keymap <CR>.

Folder structure

├── repro.lua
└── repro.py

1 directory, 2 files

Reproduction steps

  1. Open vim with nvim --clean +'so repro.lua'
  2. Close the lazy window after successful installation of plugins
  3. Execute :MasonToolsInstall and wait for debugpy debugger install
  4. Open the provided python file with :e repro.py
  5. Set a breakpoint on the second var with <leader>db
  6. Start the debugger with <leader>dc
  7. Go to the Dap scopes window and try to toggle any variable with <CR> (this works fine)
  8. Now edit a different variable with e and try to toggle any variable again.
  9. Toggle doesn't work normally

Code snippets

repro.lua

-- DO NOT change the paths
local root = vim.fn.fnamemodify("./.repro", ":p")
root = root:sub(-1) == "/" and root or root .. "/"

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. name
end

--------------------------------------------------------------------------------

vim.g.mapleader = " "

--------------------------------------------------------------------------------

local plugins = {
  {
    "williamboman/mason.nvim",
    lazy = false,
    cmd = "Mason",
    opts = {
      ui = {
        check_outdated_packages_on_open = false,
        keymaps = {
          update_all_packages = "noop",
        },
      },
    },
  },
  {
    "WhoIsSethDaniel/mason-tool-installer.nvim",
    dependencies = "williamboman/mason.nvim",
    cmd = "MasonToolsInstall",
    opts = {
      run_on_start = false,
      ensure_installed = { "debugpy" },
    },
  },
  {
    "mfussenegger/nvim-dap",
    dependencies = "rcarriga/nvim-dap-ui",
    keys = {
      { "<leader>db", function() require("dap").toggle_breakpoint() end, desc = "Toggle Breakpoint (F9)" },
      {
        "<leader>dc",
        function() require("dap").continue() end,
        desc = "Start/Continue (F5)",
      },
    },
    config = function()
      local dap = require("dap")
      local dapui = require("dapui")
      dap.listeners.before.attach["dapui_config"] = dapui.open
      dap.listeners.before.launch["dapui_config"] = dapui.open
    end,
  },
  {
    "rcarriga/nvim-dap-ui",
    lazy = true,
    config = true,
  },
  {
    "mfussenegger/nvim-dap-python",
    dependencies = { "mfussenegger/nvim-dap", "rcarriga/nvim-dap-ui" },
    ft = "python",
    config = function()
      local mason_registry = require("mason-registry")
      local python_dap = mason_registry.get_package("debugpy")

      if python_dap then
        local dap_executable = python_dap:get_install_path() .. "/venv/bin/python"
        ---https://github.com/mfussenegger/nvim-dap-python?tab=readme-ov-file#usage
        require("dap-python").setup(dap_executable)
      end
    end,
  },
}

--------------------------------------------------------------------------------

local lazypath = root .. "/plugins/lazy.nvim"
---@diagnostic disable-next-line: undefined-field
if not (vim.uv or vim.loop).fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "https://github.com/folke/lazy.nvim.git",
    "--branch=stable",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

repro.py

if __name__ == "__main__":
    myvar1 = "test"
    myvar2 = "test"
    print(myvar2)
@serranomorante
Copy link
Contributor Author

serranomorante commented Feb 7, 2024

I added a PR that fixes this but you have to edit the variable (same value or any other). If you just escape insert mode and try to execute any other action (like expand) it will always come back to the prompt until you save the value.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant