Skip to content
Merged
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
4 changes: 2 additions & 2 deletions lua/marksman/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,8 @@ local function setup_window_keymaps(buf, marks, project_name, mark_info, search_
prompt = "Clear all marks in this project?",
}, function(choice)
if choice == "Yes" then
local storage = require("marksman.storage")
storage.clear_all_marks()
local marksman = require("marksman")
marksman.clear_all_marks()
close_window()
notify("󰃀 All marks cleared", vim.log.levels.INFO)
end
Expand Down
39 changes: 39 additions & 0 deletions tests/marksman_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,45 @@ describe("marksman.nvim", function()
result = marksman.delete_mark("nonexistent")
assert.is_false(result.success)
end)

-- Test case for the clear all marks bug fix
-- This ensures that clearing all marks through the UI properly persists the changes
it("clears all marks and persists changes", function()
vim.cmd("edit " .. test_file)

-- Add multiple marks at different positions
marksman.add_mark("mark1")
vim.fn.cursor(2, 1)
marksman.add_mark("mark2")
vim.fn.cursor(3, 1)
marksman.add_mark("mark3")

-- Verify marks were added
assert.equals(3, marksman.get_marks_count())

-- Mock vim.ui.select to automatically confirm the clear action
local original_select = vim.ui.select
vim.ui.select = function(choices, opts, callback)
if opts.prompt == "Clear all marks in this project?" then
callback("Yes") -- Simulate user selecting "Yes"
end
end

-- Clear all marks (this should trigger the save mechanism)
marksman.clear_all_marks()

-- Restore original function
vim.ui.select = original_select

-- Verify marks were cleared immediately
assert.equals(0, marksman.get_marks_count())

-- Wait for any debounced save operations to complete
vim.wait(200)

-- Verify marks remain cleared after save delay
assert.equals(0, marksman.get_marks_count(), "Marks should remain cleared after debounced save")
end)
end)

describe("mark search and filtering", function()
Expand Down