Skip to content

Commit

Permalink
fix: variable_above_alwaysprompt key - closes #115
Browse files Browse the repository at this point in the history
This was because some duplicate key setup logic had crept in - removed.
  • Loading branch information
andrewferrier committed Aug 30, 2024
1 parent 72dcb51 commit 9d09893
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 29 deletions.
28 changes: 0 additions & 28 deletions lua/debugprint/setup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,34 +121,6 @@ M.map_keys_and_commands = function(global_opts)
desc = "Comment/uncomment all debugprint statements in the current buffer",
})

map_key("x", global_opts.keymaps.visual.variable_below, {
callback = function()
feedkeys(debugprint.debugprint({ variable = true }))
end,
desc = "Variable debug below current line",
})

map_key("x", global_opts.keymaps.visual.variable_above, {
callback = function()
feedkeys(debugprint.debugprint({
above = true,
variable = true,
}))
end,
desc = "Variable debug above current line",
})

map_key("n", global_opts.keymaps.normal.variable_above_alwaysprompt, {
callback = function()
return debugprint.debugprint({
above = true,
variable = true,
ignore_treesitter = true,
})
end,
desc = "Variable debug above current line (always prompt})",
})

if global_opts.commands.delete_debug_prints then
vim.api.nvim_create_user_command(
global_opts.commands.delete_debug_prints,
Expand Down
27 changes: 26 additions & 1 deletion tests/debugprint.lua
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ describe("can handle treesitter identifiers", function()
assert.are.same(vim.api.nvim_win_get_cursor(0), { 2, 9 })
end)

it("disabled at function level", function()
it("always prompt below", function()
debugprint.setup({
keymaps = { normal = { variable_below_alwaysprompt = "zxa" } },
})
Expand All @@ -994,6 +994,31 @@ describe("can handle treesitter identifiers", function()
assert.are.same(vim.api.nvim_win_get_cursor(0), { 2, 10 })
end)

it("always prompt above", function()
debugprint.setup({
keymaps = { normal = { variable_above_alwaysprompt = "zxb" } },
})

local filename = init_file({
"function x()",
" local xyz = 3",
"end",
}, "lua", 2, 10)

feedkeys("zxb<BS><BS><BS>apple<CR>")

check_lines({
"function x()",
" print('DEBUGPRINT[1]: "
.. filename
.. ":2: apple=' .. vim.inspect(apple))",
" local xyz = 3",
"end",
})

assert.are.same(vim.api.nvim_win_get_cursor(0), { 3, 10 })
end)

it("special case dot expression (lua)", function()
debugprint.setup()

Expand Down

0 comments on commit 9d09893

Please sign in to comment.