From 1c3ff2f2006bb87249a14eda9703861fe759f577 Mon Sep 17 00:00:00 2001 From: raiguard Date: Sun, 12 Dec 2021 20:30:02 -0700 Subject: Fix harpoon-remove logic --- harpoon.kak | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/harpoon.kak b/harpoon.kak index b2e1d29..85deac6 100644 --- a/harpoon.kak +++ b/harpoon.kak @@ -25,8 +25,9 @@ define-command -params 1 -docstring "Navigate to the file at the specified index define-command -params ..1 -docstring "Add the current file to the list at the index or at the end" harpoon-add %{ lua %arg{1} %val{bufname} %opt{harpoon_buffers} %{ local index, bufname = args() + index = tonumber(index) or nil -- Index is optional - if not index or (type(index) == "string" and #index == 0) then + if not index then -- Find the lowest available index local buffers = {} for i = 3, #arg do @@ -46,10 +47,11 @@ define-command -params ..1 -docstring "Add the current file to the list at the i define-command -params ..1 -docstring "Remove the file at the specified index" harpoon-remove %{ lua %arg{1} %{ local index = args() - if not index or #index == 0 then - kak.set_option("global", "harpoon_buffers") + index = tonumber(index) or nil + if index then + kak.set_option("-remove", "global", "harpoon_buffers", index.."=") else - kak.set_option("-remove", "global", "harpoon_buffers", index.."=foo") + kak.set_option("global", "harpoon_buffers") end } } -- cgit v1.2.3