Skip to content

Commit 96a9dfe

Browse files
committed
fix: stop wrapped bullets at whitespace separators
1 parent 0800c82 commit 96a9dfe

2 files changed

Lines changed: 23 additions & 3 deletions

File tree

‎lua/bullets/actions.lua‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ local function parse_static(line)
2424
end
2525
if not marker then
2626
indent, marker, spacing, text = line:match("^(%s*)([%*.]+)(%s+)(.*)$")
27-
if marker and not (marker:match("^%*+$") or marker:match("^%.+$")) then
27+
if marker and (marker == "*" or not (marker:match("^%*+$") or marker:match("^%.+$"))) then
2828
marker = nil
2929
end
3030
end
@@ -42,7 +42,7 @@ local function parse_static(line)
4242
end
4343

4444
local function parse_standard(line)
45-
local indent, marker, spacing, text = line:match("^(%s*)([-+])(%s+)(.*)$")
45+
local indent, marker, spacing, text = line:match("^(%s*)([-*+])(%s+)(.*)$")
4646
if not marker then
4747
return nil
4848
end
@@ -280,7 +280,7 @@ local function wrapped_owner(lnum, line)
280280
local current_indent = #(line:match("^%s*") or "")
281281
for row = lnum - 1, 1, -1 do
282282
local previous_line = vim.api.nvim_buf_get_lines(0, row - 1, row, false)[1]
283-
if previous_line == "" then
283+
if previous_line:match("^%s*$") then
284284
return nil
285285
end
286286

‎test/wrapping_bullets_spec.lua‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,24 @@ describe("wrapped bullets", function()
6565
"do that",
6666
}, helpers.get_lines())
6767
end)
68+
69+
active_it("does not insert wrapped bullets after whitespace-only separators", function()
70+
helpers.new_buffer({
71+
"# Hello there",
72+
"- do this",
73+
" this is the second line of the first bullet",
74+
" ",
75+
" no bullets after this line",
76+
})
77+
helpers.feedkeys("A<CR>")
78+
helpers.feedkeys("ido that<Esc>")
79+
assert.are.same({
80+
"# Hello there",
81+
"- do this",
82+
" this is the second line of the first bullet",
83+
" ",
84+
" no bullets after this line",
85+
"do that",
86+
}, helpers.get_lines())
87+
end)
6888
end)

0 commit comments

Comments
 (0)