Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions lua/bullets/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ local function checkbox_continuation_prefix(bullet, prefix)
end

local function is_empty_bullet_text(text)
if text == '' then
if text:match '^%s*$' then
return true
end

Expand Down Expand Up @@ -908,17 +908,6 @@ function M.insert_new_bullet()
return ''
end

if bullet.text:match '^%s*$' and config.options.delete_last_bullet_if_empty == 1 then
if mode ~= 'n' then
vim.api.nvim_feedkeys(keys '<Esc>ddi', 'n', false)
return ''
end

vim.api.nvim_buf_set_lines(0, lnum - 1, lnum, false, {})
vim.cmd.startinsert()
return ''
end

if is_empty_bullet_text(bullet.text) and delete_empty_bullet(lnum, bullet, mode) then
return ''
end
Expand Down
1 change: 1 addition & 0 deletions openspec/specs/list-continuation/spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ The plugin SHALL handle an empty continued list item according to `delete_last_b
- AND the current line is an empty list item
- WHEN bullet insertion is triggered
- THEN the empty list item is removed
- AND the cursor remains on the same line

#### Scenario: Promote empty item {#LC-004}

Expand Down
11 changes: 5 additions & 6 deletions test/bullets_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -220,17 +220,16 @@ describe('Bullets.vim', function()
helpers.new_buffer {
'# Hello there',
'- this is the first bullet',
'- ',
}
-- First CR creates "- " empty bullet, second CR on empty bullet deletes it
helpers.feedkeys 'A<CR><CR>'
-- CR on empty bullet deletes it
helpers.feedkeys 'A<CR>'
local lines = helpers.get_lines()
-- Strip trailing empty lines before comparison.
while #lines > 0 and lines[#lines] == '' do
table.remove(lines)
end

assert.are.same({
'# Hello there',
'- this is the first bullet',
'', -- cursor should be here, we do not want to remove the line
}, lines)
end)

Expand Down