Skip to content

Commit 9d09893

Browse files
committed
fix: variable_above_alwaysprompt key - closes #115
This was because some duplicate key setup logic had crept in - removed.
1 parent 72dcb51 commit 9d09893

File tree

2 files changed

+26
-29
lines changed

2 files changed

+26
-29
lines changed

lua/debugprint/setup.lua

-28
Original file line numberDiff line numberDiff line change
@@ -121,34 +121,6 @@ M.map_keys_and_commands = function(global_opts)
121121
desc = "Comment/uncomment all debugprint statements in the current buffer",
122122
})
123123

124-
map_key("x", global_opts.keymaps.visual.variable_below, {
125-
callback = function()
126-
feedkeys(debugprint.debugprint({ variable = true }))
127-
end,
128-
desc = "Variable debug below current line",
129-
})
130-
131-
map_key("x", global_opts.keymaps.visual.variable_above, {
132-
callback = function()
133-
feedkeys(debugprint.debugprint({
134-
above = true,
135-
variable = true,
136-
}))
137-
end,
138-
desc = "Variable debug above current line",
139-
})
140-
141-
map_key("n", global_opts.keymaps.normal.variable_above_alwaysprompt, {
142-
callback = function()
143-
return debugprint.debugprint({
144-
above = true,
145-
variable = true,
146-
ignore_treesitter = true,
147-
})
148-
end,
149-
desc = "Variable debug above current line (always prompt})",
150-
})
151-
152124
if global_opts.commands.delete_debug_prints then
153125
vim.api.nvim_create_user_command(
154126
global_opts.commands.delete_debug_prints,

tests/debugprint.lua

+26-1
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,7 @@ describe("can handle treesitter identifiers", function()
969969
assert.are.same(vim.api.nvim_win_get_cursor(0), { 2, 9 })
970970
end)
971971

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

997+
it("always prompt above", function()
998+
debugprint.setup({
999+
keymaps = { normal = { variable_above_alwaysprompt = "zxb" } },
1000+
})
1001+
1002+
local filename = init_file({
1003+
"function x()",
1004+
" local xyz = 3",
1005+
"end",
1006+
}, "lua", 2, 10)
1007+
1008+
feedkeys("zxb<BS><BS><BS>apple<CR>")
1009+
1010+
check_lines({
1011+
"function x()",
1012+
" print('DEBUGPRINT[1]: "
1013+
.. filename
1014+
.. ":2: apple=' .. vim.inspect(apple))",
1015+
" local xyz = 3",
1016+
"end",
1017+
})
1018+
1019+
assert.are.same(vim.api.nvim_win_get_cursor(0), { 3, 10 })
1020+
end)
1021+
9971022
it("special case dot expression (lua)", function()
9981023
debugprint.setup()
9991024

0 commit comments

Comments
 (0)