Skip to content

Commit

Permalink
fix: use save instead of toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
ThePrimeagen committed Nov 29, 2023
1 parent b6800cb commit d98c514
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lua/harpoon2/buffer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function M.setup_autocmds_and_keymaps(bufnr)
-- TODO: Update these to use the new autocmd api
vim.cmd(
string.format(
"autocmd BufWriteCmd <buffer=%s> lua require('harpoon2').ui:on_menu_save()",
"autocmd BufWriteCmd <buffer=%s> lua require('harpoon2').ui:save()",
bufnr
)
)
Expand All @@ -77,7 +77,7 @@ function M.setup_autocmds_and_keymaps(bufnr)
if global_config.save_on_change then
vim.cmd(
string.format(
"autocmd TextChanged,TextChangedI <buffer=%s> lua require('harpoon2').ui:on_menu_save()",
"autocmd TextChanged,TextChangedI <buffer=%s> lua require('harpoon2').ui:save()",
bufnr
)
)
Expand Down
2 changes: 1 addition & 1 deletion lua/harpoon2/test/ui_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe("harpoon", function()
harpoon.ui:toggle_quick_menu(harpoon:list())
table.remove(created_files, 2)
Buffer.set_contents(harpoon.ui.bufnr, created_files)
harpoon.ui:toggle_quick_menu()
harpoon.ui:save()

eq(harpoon:list():length(), 2)
eq(harpoon:list():display(), created_files)
Expand Down
2 changes: 1 addition & 1 deletion lua/harpoon2/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ function HarpoonUI:select_menu_item()
self:close_menu()
end

function HarpoonUI:on_menu_save()
function HarpoonUI:save()
local list = Buffer.get_contents(self.bufnr)
self.active_list:resolve_displayed(list)
end
Expand Down

0 comments on commit d98c514

Please sign in to comment.