From 9bf3299200674271e93cd166986a853da85f6dcd Mon Sep 17 00:00:00 2001 From: raiguard Date: Thu, 23 Dec 2021 21:00:48 -0700 Subject: Fix crash when there are gaps in the list --- harpoon.kak | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/harpoon.kak b/harpoon.kak index 1af38b8..e10c2e1 100644 --- a/harpoon.kak +++ b/harpoon.kak @@ -10,7 +10,7 @@ define-command harpoon-nav -params 1 -docstring "Navigate to the file at the spe for i = 2, #arg do local index, bufname = string.match(arg[i], "(%d+)=(.*)") index = tonumber(index) - table.insert(buffers, index, bufname) + buffers[index] = bufname end if buffers[to_index] then @@ -33,7 +33,7 @@ define-command harpoon-add -params ..1 -docstring "Add the current file to the l for i = 3, #arg do local index, bufname = string.match(arg[i], "(%d+)=(.*)") index = tonumber(index) - table.insert(buffers, index, bufname) + buffers[index] = bufname end -- This will handle gaps in the list as well, since # will return the first contiguous section index = #buffers + 1 @@ -62,7 +62,7 @@ define-command harpoon-add-or-nav -params 1 -docstring "Add or navigate to the f for i = 2, #arg do local index, bufname = string.match(arg[i], "(%d+)=(.*)") index = tonumber(index) - table.insert(buffers, index, bufname) + buffers[index] = bufname end local index = args() -- cgit v1.2.3