Skip to content

Commit 4d49972

Browse files
author
Andrew Ferrier
committed
feat: Move counter to the beginning
1 parent 5501c0d commit 4d49972

File tree

2 files changed

+19
-22
lines changed

2 files changed

+19
-22
lines changed

lua/debugprint/init.lua

+1-4
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,10 @@ local debuginfo = function(variable_name)
1313
local current_line = vim.api.nvim_win_get_cursor(0)[1]
1414
counter = counter + 1
1515

16-
local line = "DEBUG: "
16+
local line = "DEBUG[" .. counter .. "]: "
1717
.. vim.fn.expand("%:t")
1818
.. ":"
1919
.. current_line
20-
.. " ["
21-
.. counter
22-
.. "]"
2320

2421
if variable_name ~= nil then
2522
line = line .. ": " .. variable_name .. "="

tests/debugprint.lua

+18-18
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ describe("can do basic debug statement insertion", function()
4848

4949
check_lines({
5050
"foo",
51-
"print('DEBUG: " .. filename .. ":1 [1]')",
51+
"print('DEBUG[1]: " .. filename .. ":1')",
5252
"bar",
5353
})
5454
end)
@@ -64,7 +64,7 @@ describe("can do basic debug statement insertion", function()
6464
feedkeys("dqP")
6565

6666
check_lines({
67-
"print('DEBUG: " .. filename .. ":1 [1]')",
67+
"print('DEBUG[1]: " .. filename .. ":1')",
6868
"foo",
6969
"bar",
7070
})
@@ -82,8 +82,8 @@ describe("can do basic debug statement insertion", function()
8282
feedkeys("dqP")
8383

8484
check_lines({
85-
"print('DEBUG: " .. filename .. ":1 [1]')",
86-
"print('DEBUG: " .. filename .. ":2 [2]')",
85+
"print('DEBUG[1]: " .. filename .. ":1')",
86+
"print('DEBUG[2]: " .. filename .. ":2')",
8787
"foo",
8888
"bar",
8989
})
@@ -102,7 +102,7 @@ describe("can do basic debug statement insertion", function()
102102
check_lines({
103103
"foo",
104104
"bar",
105-
"print('DEBUG: " .. filename .. ":2 [1]')",
105+
"print('DEBUG[1]: " .. filename .. ":2')",
106106
})
107107
end)
108108
end)
@@ -124,9 +124,9 @@ describe("can do variable debug statement insertion", function()
124124

125125
check_lines({
126126
"foo",
127-
"print('DEBUG: "
127+
"print('DEBUG[1]: "
128128
.. filename
129-
.. ":1 [1]: banana=' .. vim.inspect(banana))",
129+
.. ":1: banana=' .. vim.inspect(banana))",
130130
"bar",
131131
})
132132
end)
@@ -142,9 +142,9 @@ describe("can do variable debug statement insertion", function()
142142
feedkeys("dQPbanana<CR>")
143143

144144
check_lines({
145-
"print('DEBUG: "
145+
"print('DEBUG[1]: "
146146
.. filename
147-
.. ":1 [1]: banana=' .. vim.inspect(banana))",
147+
.. ":1: banana=' .. vim.inspect(banana))",
148148
"foo",
149149
"bar",
150150
})
@@ -168,7 +168,7 @@ describe("can do various file types", function()
168168

169169
check_lines({
170170
"foo",
171-
'echo "DEBUG: ' .. filename .. ':1 [1]"',
171+
'echo "DEBUG[1]: ' .. filename .. ':1"',
172172
"bar",
173173
})
174174
end)
@@ -185,7 +185,7 @@ describe("can do various file types", function()
185185

186186
check_lines({
187187
"foo",
188-
'echo "DEBUG: ' .. filename .. ':1 [1]: banana=" .. banana',
188+
'echo "DEBUG[1]: ' .. filename .. ':1: banana=" .. banana',
189189
"bar",
190190
})
191191
end)
@@ -225,7 +225,7 @@ describe("can do indenting correctly", function()
225225

226226
check_lines({
227227
"function()",
228-
" print('DEBUG: " .. filename .. ":1 [1]')",
228+
" print('DEBUG[1]: " .. filename .. ":1')",
229229
"end",
230230
})
231231
end)
@@ -243,7 +243,7 @@ describe("can do indenting correctly", function()
243243

244244
check_lines({
245245
"function()",
246-
" print('DEBUG: " .. filename .. ":2 [1]')",
246+
" print('DEBUG[1]: " .. filename .. ":2')",
247247
"end",
248248
})
249249
end)
@@ -260,7 +260,7 @@ describe("can do indenting correctly", function()
260260
feedkeys("dqP")
261261

262262
check_lines({
263-
"print('DEBUG: " .. filename .. ":1 [1]')",
263+
"print('DEBUG[1]: " .. filename .. ":1')",
264264
"function()",
265265
"end",
266266
})
@@ -280,7 +280,7 @@ describe("can do indenting correctly", function()
280280

281281
check_lines({
282282
"function()",
283-
"\tprint('DEBUG: " .. filename .. ":1 [1]')",
283+
"\tprint('DEBUG[1]: " .. filename .. ":1')",
284284
"end",
285285
})
286286
end)
@@ -315,7 +315,7 @@ describe("add custom filetype with setup()", function()
315315

316316
check_lines({
317317
"foo",
318-
"foo('DEBUG: " .. filename .. ":1 [1]')",
318+
"foo('DEBUG[1]: " .. filename .. ":1')",
319319
"bar",
320320
})
321321
end)
@@ -332,7 +332,7 @@ describe("add custom filetype with setup()", function()
332332

333333
check_lines({
334334
"foo",
335-
"foo('DEBUG: " .. filename .. ":1 [1]: apple=' .. apple)",
335+
"foo('DEBUG[1]: " .. filename .. ":1: apple=' .. apple)",
336336
"bar",
337337
})
338338
end)
@@ -367,7 +367,7 @@ describe("add custom filetype with add_custom_filetypes()", function()
367367

368368
check_lines({
369369
"foo",
370-
"bar('DEBUG: " .. filename .. ":1 [1]')",
370+
"bar('DEBUG[1]: " .. filename .. ":1')",
371371
"bar",
372372
})
373373
end)

0 commit comments

Comments
 (0)