From 56993258915e85024ce920593902d54ffb593a1e Mon Sep 17 00:00:00 2001 From: Dorian Karter Date: Wed, 17 Jun 2026 00:37:15 -0500 Subject: [PATCH] fix: keep line after deleting empty bullet --- lua/bullets/actions.lua | 13 +------------ openspec/specs/list-continuation/spec.md | 1 + test/bullets_spec.lua | 11 +++++------ 3 files changed, 7 insertions(+), 18 deletions(-) diff --git a/lua/bullets/actions.lua b/lua/bullets/actions.lua index cc54862..6e0ccb5 100644 --- a/lua/bullets/actions.lua +++ b/lua/bullets/actions.lua @@ -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 @@ -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 '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 diff --git a/openspec/specs/list-continuation/spec.md b/openspec/specs/list-continuation/spec.md index b338f74..17de5d1 100644 --- a/openspec/specs/list-continuation/spec.md +++ b/openspec/specs/list-continuation/spec.md @@ -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} diff --git a/test/bullets_spec.lua b/test/bullets_spec.lua index 6f6fa09..853735d 100644 --- a/test/bullets_spec.lua +++ b/test/bullets_spec.lua @@ -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 on empty bullet deletes it + helpers.feedkeys 'A' 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)